test_functional_get.cpp 2.2 KB

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