From 7ad274b96386132b4f9f21b58fc05d038c748053 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 23 Jun 2021 11:08:34 -0500 Subject: [PATCH] Add tests of tuple_element/size for cv qualified pairs. --- testing/pair.cu | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/testing/pair.cu b/testing/pair.cu index e0a5e71e5..f5f6e92b5 100644 --- a/testing/pair.cu +++ b/testing/pair.cu @@ -213,33 +213,42 @@ struct TestPairGet }; SimpleUnitTest TestPairGetInstance; +using PairConstVolatileTypes = + unittest::type_list, thrust::pair const, + thrust::pair const volatile>; -void TestPairTupleSize(void) +template +struct TestPairTupleSize { - int result = thrust::tuple_size< thrust::pair >::value; - ASSERT_EQUAL(2, result); - - // test const pair - int const_result = thrust::tuple_size< thrust::pair const >::value; - ASSERT_EQUAL(2, const_result); + void operator()() + { + ASSERT_EQUAL(2, static_cast(thrust::tuple_size::value)); + } }; -DECLARE_UNITTEST(TestPairTupleSize); +SimpleUnitTest TestPairTupleSizeInstance; void TestPairTupleElement(void) { - typedef thrust::tuple_element<0, thrust::pair >::type type0; - typedef thrust::tuple_element<1, thrust::pair >::type type1; - - ASSERT_EQUAL_QUIET(typeid(int), typeid(type0)); - ASSERT_EQUAL_QUIET(typeid(float), typeid(type1)); - - // test const pair - typedef thrust::tuple_element<0, thrust::pair const>::type const_type0; - typedef thrust::tuple_element<1, thrust::pair const>::type const_type1; - - ASSERT_EQUAL_QUIET(typeid(int const), typeid(const_type0)); - ASSERT_EQUAL_QUIET(typeid(float const), typeid(const_type1)); + using type0 = thrust::tuple_element<0, thrust::pair >::type; + using type1 = thrust::tuple_element<1, thrust::pair >::type; + static_assert(std::is_same::value,""); + static_assert(std::is_same::value,""); + + using c_type0 = thrust::tuple_element<0, thrust::pair const>::type; + using c_type1 = thrust::tuple_element<1, thrust::pair const>::type; + static_assert(std::is_same::value,""); + static_assert(std::is_same::value,""); + + using v_type0 = thrust::tuple_element<0, thrust::pair volatile>::type; + using v_type1 = thrust::tuple_element<1, thrust::pair volatile>::type; + static_assert(std::is_same::value,""); + static_assert(std::is_same::value,""); + + using cv_type0 = thrust::tuple_element<0, thrust::pair const volatile>::type; + using cv_type1 = thrust::tuple_element<1, thrust::pair const volatile>::type; + static_assert(std::is_same::value,""); + static_assert(std::is_same::value,""); }; DECLARE_UNITTEST(TestPairTupleElement);