test_functional_identity.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. // See http://boostorg.github.com/compute for more information.
  9. //---------------------------------------------------------------------------//
  10. #define BOOST_TEST_MODULE TestFunctionalIdentity
  11. #include <boost/test/unit_test.hpp>
  12. #include <boost/compute/system.hpp>
  13. #include <boost/compute/algorithm/transform.hpp>
  14. #include <boost/compute/container/vector.hpp>
  15. #include <boost/compute/functional/identity.hpp>
  16. #include "check_macros.hpp"
  17. #include "context_setup.hpp"
  18. namespace compute = boost::compute;
  19. BOOST_AUTO_TEST_CASE(copy_with_identity_transform)
  20. {
  21. int data[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
  22. compute::vector<int> input(data, data + 8, queue);
  23. compute::vector<int> output(8, context);
  24. compute::transform(
  25. input.begin(), input.end(), output.begin(), compute::identity<int>(), queue
  26. );
  27. CHECK_RANGE_EQUAL(
  28. int, 8, output, (1, 2, 3, 4, 5, 6, 7, 8)
  29. );
  30. }
  31. BOOST_AUTO_TEST_SUITE_END()