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

Commit

Permalink
Tuple Algorithms: Add tests for tuple_subset & tuple_for_each
Browse files Browse the repository at this point in the history
  • Loading branch information
bjude authored and brycelelbach committed Oct 28, 2019
1 parent 9ac969a commit 4b55818
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions testing/tuple_algorithms.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -25,6 +35,16 @@ void test_tuple_transform()
ASSERT_EQUAL_QUIET(t1, std::make_tuple(0, 4, 9.8596));
}
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

0 comments on commit 4b55818

Please sign in to comment.