Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Add tests of tuple_element/size for cv qualified pairs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhemstad committed Jun 23, 2021
1 parent c345435 commit 7ad274b
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions testing/pair.cu
Original file line number Diff line number Diff line change
Expand Up @@ -213,33 +213,42 @@ struct TestPairGet
};
SimpleUnitTest<TestPairGet, BuiltinNumericTypes> TestPairGetInstance;

using PairConstVolatileTypes =
unittest::type_list<thrust::pair<int, float>, thrust::pair<int, float> const,
thrust::pair<int, float> const volatile>;

void TestPairTupleSize(void)
template <typename Pair>
struct TestPairTupleSize
{
int result = thrust::tuple_size< thrust::pair<int,int> >::value;
ASSERT_EQUAL(2, result);

// test const pair
int const_result = thrust::tuple_size< thrust::pair<int,int> const >::value;
ASSERT_EQUAL(2, const_result);
void operator()()
{
ASSERT_EQUAL(2, static_cast<int>(thrust::tuple_size<Pair>::value));
}
};
DECLARE_UNITTEST(TestPairTupleSize);
SimpleUnitTest<TestPairTupleSize, PairConstVolatileTypes> TestPairTupleSizeInstance;


void TestPairTupleElement(void)
{
typedef thrust::tuple_element<0, thrust::pair<int, float> >::type type0;
typedef thrust::tuple_element<1, thrust::pair<int, float> >::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<int, float> const>::type const_type0;
typedef thrust::tuple_element<1, thrust::pair<int, float> 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<int, float> >::type;
using type1 = thrust::tuple_element<1, thrust::pair<int, float> >::type;
static_assert(std::is_same<int, type0>::value,"");
static_assert(std::is_same<float, type1>::value,"");

using c_type0 = thrust::tuple_element<0, thrust::pair<int, float> const>::type;
using c_type1 = thrust::tuple_element<1, thrust::pair<int, float> const>::type;
static_assert(std::is_same<int const, c_type0>::value,"");
static_assert(std::is_same<float const, c_type1>::value,"");

using v_type0 = thrust::tuple_element<0, thrust::pair<int, float> volatile>::type;
using v_type1 = thrust::tuple_element<1, thrust::pair<int, float> volatile>::type;
static_assert(std::is_same<int volatile, v_type0>::value,"");
static_assert(std::is_same<float volatile, v_type1>::value,"");

using cv_type0 = thrust::tuple_element<0, thrust::pair<int, float> const volatile>::type;
using cv_type1 = thrust::tuple_element<1, thrust::pair<int, float> const volatile>::type;
static_assert(std::is_same<int const volatile, cv_type0>::value,"");
static_assert(std::is_same<float const volatile, cv_type1>::value,"");
};
DECLARE_UNITTEST(TestPairTupleElement);

Expand Down

0 comments on commit 7ad274b

Please sign in to comment.