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 TestFunctionalGet
12 #include <boost/test/unit_test.hpp>
13
14 #include <boost/type_traits.hpp>
15 #include <boost/static_assert.hpp>
16
17 #include <boost/compute/types/pair.hpp>
18 #include <boost/compute/types/tuple.hpp>
19 #include <boost/compute/types/fundamental.hpp>
20 #include <boost/compute/functional/get.hpp>
21 #include <boost/compute/type_traits/result_of.hpp>
22
23 namespace compute = boost::compute;
24
BOOST_AUTO_TEST_CASE(get_vector_result_type)25 BOOST_AUTO_TEST_CASE(get_vector_result_type)
26 {
27 BOOST_STATIC_ASSERT((
28 boost::is_same<
29 boost::compute::result_of<
30 compute::get<0>(compute::float4_)
31 >::type,
32 float
33 >::value
34 ));
35 BOOST_STATIC_ASSERT((
36 boost::is_same<
37 boost::compute::result_of<
38 compute::get<1>(compute::int2_)
39 >::type,
40 int
41 >::value
42 ));
43 }
44
BOOST_AUTO_TEST_CASE(get_pair_result_type)45 BOOST_AUTO_TEST_CASE(get_pair_result_type)
46 {
47 BOOST_STATIC_ASSERT((
48 boost::is_same<
49 boost::compute::result_of<
50 compute::get<0>(std::pair<int, float>)
51 >::type,
52 int
53 >::value
54 ));
55 BOOST_STATIC_ASSERT((
56 boost::is_same<
57 boost::compute::result_of<
58 compute::get<1>(std::pair<compute::float2_, compute::char4_>)
59 >::type,
60 compute::char4_
61 >::value
62 ));
63 }
64
BOOST_AUTO_TEST_CASE(get_tuple_result_type)65 BOOST_AUTO_TEST_CASE(get_tuple_result_type)
66 {
67 BOOST_STATIC_ASSERT((
68 boost::is_same<
69 boost::compute::result_of<
70 compute::get<0>(boost::tuple<int, int, double>)
71 >::type,
72 int
73 >::value
74 ));
75 BOOST_STATIC_ASSERT((
76 boost::is_same<
77 boost::compute::result_of<
78 compute::get<2>(boost::tuple<char, int, float>)
79 >::type,
80 float
81 >::value
82 ));
83 }
84