#include #include template struct TestMin { void operator()() { // 2 < 3 T two(2), three(3); ASSERT_EQUAL(two, ::cuda::std::min(two, three)); ASSERT_EQUAL(two, ::cuda::std::min(two, three, ::cuda::std::less())); ASSERT_EQUAL(two, ::cuda::std::min(three, two)); ASSERT_EQUAL(two, ::cuda::std::min(three, two, ::cuda::std::less())); ASSERT_EQUAL(three, ::cuda::std::min(two, three, ::cuda::std::greater())); ASSERT_EQUAL(three, ::cuda::std::min(three, two, ::cuda::std::greater())); using KV = key_value; KV two_and_two(two, two); KV two_and_three(two, three); // the first element breaks ties ASSERT_EQUAL_QUIET(two_and_two, ::cuda::std::min(two_and_two, two_and_three)); ASSERT_EQUAL_QUIET(two_and_three, ::cuda::std::min(two_and_three, two_and_two)); ASSERT_EQUAL_QUIET(two_and_two, ::cuda::std::min(two_and_two, two_and_three, ::cuda::std::less())); ASSERT_EQUAL_QUIET(two_and_three, ::cuda::std::min(two_and_three, two_and_two, ::cuda::std::less())); ASSERT_EQUAL_QUIET(two_and_two, ::cuda::std::min(two_and_two, two_and_three, ::cuda::std::greater())); ASSERT_EQUAL_QUIET(two_and_three, ::cuda::std::min(two_and_three, two_and_two, ::cuda::std::greater())); } }; SimpleUnitTest TestMinInstance; template struct TestMax { void operator()() { // 2 < 3 T two(2), three(3); ASSERT_EQUAL(three, ::cuda::std::max(two, three)); ASSERT_EQUAL(three, ::cuda::std::max(two, three, ::cuda::std::less())); ASSERT_EQUAL(three, ::cuda::std::max(three, two)); ASSERT_EQUAL(three, ::cuda::std::max(three, two, ::cuda::std::less())); ASSERT_EQUAL(two, ::cuda::std::max(two, three, ::cuda::std::greater())); ASSERT_EQUAL(two, ::cuda::std::max(three, two, ::cuda::std::greater())); using KV = key_value; KV two_and_two(two, two); KV two_and_three(two, three); // the first element breaks ties ASSERT_EQUAL_QUIET(two_and_two, ::cuda::std::max(two_and_two, two_and_three)); ASSERT_EQUAL_QUIET(two_and_three, ::cuda::std::max(two_and_three, two_and_two)); ASSERT_EQUAL_QUIET(two_and_two, ::cuda::std::max(two_and_two, two_and_three, ::cuda::std::less())); ASSERT_EQUAL_QUIET(two_and_three, ::cuda::std::max(two_and_three, two_and_two, ::cuda::std::less())); ASSERT_EQUAL_QUIET(two_and_two, ::cuda::std::max(two_and_two, two_and_three, ::cuda::std::greater())); ASSERT_EQUAL_QUIET(two_and_three, ::cuda::std::max(two_and_three, two_and_two, ::cuda::std::greater())); } }; SimpleUnitTest TestMaxInstance;