Tuple Algorithms: Add tests for tuple_subset & tuple_for_each
MODIFY
testing/tuple_algorithms.cu
testing/tuple_algorithms.cu
@@ -16,6 +16,16 @@ struct custom_square
}
};
+void test_tuple_subset()
+{
+ auto t0 = std::make_tuple(0, 2, 3.14);
+
+ auto t1 = thrust::tuple_subset(t0, std::index_sequence<2, 0>{});
+
+ ASSERT_EQUAL_QUIET(t1, std::make_tuple(3.14, 0));
+}
+DECLARE_UNITTEST(test_tuple_subset);
+
void test_tuple_transform()
{
auto t0 = std::make_tuple(0, 2, 3.14);
@@ -26,5 +36,15 @@ void test_tuple_transform()
}
DECLARE_UNITTEST(test_tuple_transform);
+void test_tuple_for_each()
+{
+ auto t = std::make_tuple(0, 2, 3.14);
+
+ thrust::tuple_for_each(t, [](auto& x) { x *= x; });
+
+ ASSERT_EQUAL_QUIET(t, std::make_tuple(0, 4, 9.8596));
+}
+DECLARE_UNITTEST(test_tuple_for_each);
+
#endif // THRUST_CPP_DIALECT >= 2011

Tuple Algorithms: Add tests for tuple_subset & tuple_for_each