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