Skip to content

Commit 4b55818

Browse files
bjudebrycelelbach
authored andcommitted
Tuple Algorithms: Add tests for tuple_subset & tuple_for_each
1 parent 9ac969a commit 4b55818

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

testing/tuple_algorithms.cu

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ struct custom_square
1616
}
1717
};
1818

19+
void test_tuple_subset()
20+
{
21+
auto t0 = std::make_tuple(0, 2, 3.14);
22+
23+
auto t1 = thrust::tuple_subset(t0, std::index_sequence<2, 0>{});
24+
25+
ASSERT_EQUAL_QUIET(t1, std::make_tuple(3.14, 0));
26+
}
27+
DECLARE_UNITTEST(test_tuple_subset);
28+
1929
void test_tuple_transform()
2030
{
2131
auto t0 = std::make_tuple(0, 2, 3.14);
@@ -25,6 +35,16 @@ void test_tuple_transform()
2535
ASSERT_EQUAL_QUIET(t1, std::make_tuple(0, 4, 9.8596));
2636
}
2737
DECLARE_UNITTEST(test_tuple_transform);
38+
39+
void test_tuple_for_each()
40+
{
41+
auto t = std::make_tuple(0, 2, 3.14);
42+
43+
thrust::tuple_for_each(t, [](auto& x) { x *= x; });
44+
45+
ASSERT_EQUAL_QUIET(t, std::make_tuple(0, 4, 9.8596));
46+
}
47+
DECLARE_UNITTEST(test_tuple_for_each);
2848

2949
#endif // THRUST_CPP_DIALECT >= 2011
3050

0 commit comments

Comments
 (0)