• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #define BOOST_TEST_MODULE TestFunctionalConvert
12 #include <boost/test/unit_test.hpp>
13 
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/algorithm/copy_n.hpp>
16 #include <boost/compute/algorithm/transform.hpp>
17 #include <boost/compute/container/vector.hpp>
18 #include <boost/compute/functional/convert.hpp>
19 
20 #include "check_macros.hpp"
21 #include "context_setup.hpp"
22 
23 namespace compute = boost::compute;
24 
BOOST_AUTO_TEST_CASE(convert_int_float)25 BOOST_AUTO_TEST_CASE(convert_int_float)
26 {
27     int data[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
28     compute::vector<int> input(8, context);
29     compute::copy_n(data, 8, input.begin(), queue);
30 
31     compute::vector<float> output(8, context);
32     compute::transform(
33         input.begin(),
34         input.end(),
35         output.begin(),
36         compute::convert<float>(),
37         queue
38     );
39     CHECK_RANGE_EQUAL(
40         float, 8, output, (1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f)
41     );
42 }
43 
44 BOOST_AUTO_TEST_SUITE_END()
45