test_clamp_range.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013 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 TestClampRange
  11. #include <boost/test/unit_test.hpp>
  12. #include <boost/compute/system.hpp>
  13. #include <boost/compute/container/vector.hpp>
  14. #include <boost/compute/experimental/clamp_range.hpp>
  15. #include "check_macros.hpp"
  16. #include "context_setup.hpp"
  17. namespace compute = boost::compute;
  18. BOOST_AUTO_TEST_CASE(clamp_float_range)
  19. {
  20. float data[] = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f };
  21. compute::vector<float> input(data, data + 8, queue);
  22. compute::vector<float> result(8, context);
  23. compute::experimental::clamp_range(
  24. input.begin(),
  25. input.end(),
  26. result.begin(),
  27. 3.f, // low
  28. 6.f, // high
  29. queue
  30. );
  31. CHECK_RANGE_EQUAL(
  32. float, 8, result,
  33. (3.f, 3.f, 3.f, 4.f, 5.f, 6.f, 6.f, 6.f)
  34. );
  35. }
  36. BOOST_AUTO_TEST_SUITE_END()