test_function_input_iterator.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 TestFunctionInputIterator
  11. #include <boost/test/unit_test.hpp>
  12. #include <iterator>
  13. #include <boost/type_traits.hpp>
  14. #include <boost/static_assert.hpp>
  15. #include <boost/compute/function.hpp>
  16. #include <boost/compute/algorithm/copy.hpp>
  17. #include <boost/compute/container/vector.hpp>
  18. #include <boost/compute/iterator/function_input_iterator.hpp>
  19. #include "check_macros.hpp"
  20. #include "context_setup.hpp"
  21. BOOST_AUTO_TEST_CASE(generate_42_doctest)
  22. {
  23. boost::compute::vector<int> result(4, context);
  24. //! [generate_42]
  25. BOOST_COMPUTE_FUNCTION(int, ret42, (),
  26. {
  27. return 42;
  28. });
  29. boost::compute::copy(
  30. boost::compute::make_function_input_iterator(ret42, 0),
  31. boost::compute::make_function_input_iterator(ret42, result.size()),
  32. result.begin(),
  33. queue
  34. );
  35. // result == { 42, 42, 42, 42 }
  36. //! [generate_42]
  37. CHECK_RANGE_EQUAL(int, 4, result, (42, 42, 42, 42));
  38. }
  39. BOOST_AUTO_TEST_SUITE_END()