Skip to content

Commit 7ad274b

Browse files
committed
Add tests of tuple_element/size for cv qualified pairs.
1 parent c345435 commit 7ad274b

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

testing/pair.cu

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -213,33 +213,42 @@ struct TestPairGet
213213
};
214214
SimpleUnitTest<TestPairGet, BuiltinNumericTypes> TestPairGetInstance;
215215

216+
using PairConstVolatileTypes =
217+
unittest::type_list<thrust::pair<int, float>, thrust::pair<int, float> const,
218+
thrust::pair<int, float> const volatile>;
216219

217-
void TestPairTupleSize(void)
220+
template <typename Pair>
221+
struct TestPairTupleSize
218222
{
219-
int result = thrust::tuple_size< thrust::pair<int,int> >::value;
220-
ASSERT_EQUAL(2, result);
221-
222-
// test const pair
223-
int const_result = thrust::tuple_size< thrust::pair<int,int> const >::value;
224-
ASSERT_EQUAL(2, const_result);
223+
void operator()()
224+
{
225+
ASSERT_EQUAL(2, static_cast<int>(thrust::tuple_size<Pair>::value));
226+
}
225227
};
226-
DECLARE_UNITTEST(TestPairTupleSize);
228+
SimpleUnitTest<TestPairTupleSize, PairConstVolatileTypes> TestPairTupleSizeInstance;
227229

228230

229231
void TestPairTupleElement(void)
230232
{
231-
typedef thrust::tuple_element<0, thrust::pair<int, float> >::type type0;
232-
typedef thrust::tuple_element<1, thrust::pair<int, float> >::type type1;
233-
234-
ASSERT_EQUAL_QUIET(typeid(int), typeid(type0));
235-
ASSERT_EQUAL_QUIET(typeid(float), typeid(type1));
236-
237-
// test const pair
238-
typedef thrust::tuple_element<0, thrust::pair<int, float> const>::type const_type0;
239-
typedef thrust::tuple_element<1, thrust::pair<int, float> const>::type const_type1;
240-
241-
ASSERT_EQUAL_QUIET(typeid(int const), typeid(const_type0));
242-
ASSERT_EQUAL_QUIET(typeid(float const), typeid(const_type1));
233+
using type0 = thrust::tuple_element<0, thrust::pair<int, float> >::type;
234+
using type1 = thrust::tuple_element<1, thrust::pair<int, float> >::type;
235+
static_assert(std::is_same<int, type0>::value,"");
236+
static_assert(std::is_same<float, type1>::value,"");
237+
238+
using c_type0 = thrust::tuple_element<0, thrust::pair<int, float> const>::type;
239+
using c_type1 = thrust::tuple_element<1, thrust::pair<int, float> const>::type;
240+
static_assert(std::is_same<int const, c_type0>::value,"");
241+
static_assert(std::is_same<float const, c_type1>::value,"");
242+
243+
using v_type0 = thrust::tuple_element<0, thrust::pair<int, float> volatile>::type;
244+
using v_type1 = thrust::tuple_element<1, thrust::pair<int, float> volatile>::type;
245+
static_assert(std::is_same<int volatile, v_type0>::value,"");
246+
static_assert(std::is_same<float volatile, v_type1>::value,"");
247+
248+
using cv_type0 = thrust::tuple_element<0, thrust::pair<int, float> const volatile>::type;
249+
using cv_type1 = thrust::tuple_element<1, thrust::pair<int, float> const volatile>::type;
250+
static_assert(std::is_same<int const volatile, cv_type0>::value,"");
251+
static_assert(std::is_same<float const volatile, cv_type1>::value,"");
243252
};
244253
DECLARE_UNITTEST(TestPairTupleElement);
245254

0 commit comments

Comments
 (0)