#include #include "../common.h" #include #include template struct Comparator; template struct Comparator, pfor::UIntToType> { static constexpr bool value = A < B; }; template using TSBefore = pfor::impl::PackSortBefore>; template using TSAfter = pfor::impl::PackSortAfter>; template using TSInsert = pfor::PackSortInsert>; template using TSort = pfor::PackSort; TEST_CASE("Pack") { using T1 = pfor::Pack<>; using T2 = pfor::Pack; using T3 = pfor::Pack; using T4 = pfor::Pack; using T5 = pfor::Pack; using U3 = pfor::Pack; using U4 = pfor::Pack; using U5 = pfor::Pack; using M0 = pfor::Pack<>; using M1 = pfor::Pack; using M2 = pfor::Pack; using M3 = pfor::Pack; using M4 = pfor::Pack; SECTION("PackGet") { TEST(REQUIRE, is_same_v, char>); TEST(REQUIRE, is_same_v, char>); TEST(REQUIRE, is_same_v, char>); TEST(REQUIRE, is_same_v, char>); TEST(REQUIRE, is_same_v, char>); TEST(REQUIRE, is_same_v, int>); TEST(REQUIRE, is_same_v, char>); TEST(REQUIRE, is_same_v, int>); TEST(REQUIRE, is_same_v, char>); TEST(REQUIRE, is_same_v, float>); TEST(REQUIRE, is_same_v, int>); TEST(REQUIRE, is_same_v, char>); } SECTION("PackAppend") { TEST(REQUIRE, is_same_v, T2>); TEST(REQUIRE, is_same_v, T3>); TEST(REQUIRE, is_same_v, T4>); } SECTION("PackPrepend") { TEST(REQUIRE, is_same_v, U3>); TEST(REQUIRE, is_same_v, U4>); TEST(REQUIRE, is_same_v, U5>); } SECTION("PackRemove") { TEST(REQUIRE, is_same_v, T3>); TEST(REQUIRE, is_same_v, pfor::Pack>); TEST(REQUIRE, is_same_v, T5>); } SECTION("PackContains") { TEST(REQUIRE_FALSE, pfor::packContains); TEST(REQUIRE, pfor::packContains); TEST(REQUIRE_FALSE, pfor::packContains); TEST(REQUIRE, pfor::packContains); TEST(REQUIRE_FALSE, pfor::packContains); TEST(REQUIRE, pfor::packContains); } SECTION("PackUniq") { using U1 = pfor::Pack<>; using U2 = pfor::Pack; using U3 = pfor::Pack; using U4 = pfor::Pack; using U5 = pfor::Pack; TEST(REQUIRE, is_same_v, U1>); TEST(REQUIRE, is_same_v, U2>); TEST(REQUIRE, is_same_v, U3>); TEST(REQUIRE, is_same_v, U4>); TEST(REQUIRE, is_same_v, U5>); } SECTION("PackSize") { TEST_IF(REQUIRE, ==, 0, pfor::packSize); TEST_IF(REQUIRE, ==, 1, pfor::packSize); TEST_IF(REQUIRE, ==, 2, pfor::packSize); TEST_IF(REQUIRE, ==, 3, pfor::packSize); TEST_IF(REQUIRE, ==, 6, pfor::packSize); } SECTION("PackMerge") { TEST(REQUIRE, is_same_v, M0>); TEST(REQUIRE, is_same_v, M0>); TEST(REQUIRE, is_same_v, M1>); TEST(REQUIRE, is_same_v, M2>); TEST(REQUIRE, is_same_v, M3>); TEST(REQUIRE, is_same_v, M4>); } SECTION("Pack sorting") { using IT0 = UIntsToPack<>; using IT1 = UIntsToPack<6, 4, 3, 8, 9, 2, 5, 3>; using ST0 = IT0; using ST1 = UIntsToPack<2, 3, 3, 4, 5, 6, 8, 9>; using ST2 = UIntsToPack<2, 3, 3, 4, 5, 6, 7, 8, 9>; using ST3 = UIntsToPack<2, 3, 3, 4, 5, 6, 7, 7, 8, 9>; using TEmpty = pfor::Pack<>; using BT1 = UIntsToPack<2, 3, 3, 4>; using AT1 = UIntsToPack<5, 6, 8, 9>; SECTION("PackSortBefore") { TEST(REQUIRE, is_same_v, TEmpty>); TEST(REQUIRE, is_same_v, TEmpty>); TEST(REQUIRE, is_same_v, BT1>); } SECTION("PackSortAfter") { TEST(REQUIRE, is_same_v, TEmpty>); TEST(REQUIRE, is_same_v, TEmpty>); TEST(REQUIRE, is_same_v, AT1>); } SECTION("PackSortInsert") { TEST(REQUIRE, is_same_v, UIntsToPack<7>>); TEST(REQUIRE, is_same_v, ST2>); TEST(REQUIRE, is_same_v, ST3>); } SECTION("PackSort") { TEST(REQUIRE, is_same_v, ST0>); TEST(REQUIRE, is_same_v, ST1>); } } }