#include #include "../common.h" #include template struct Sizeof { static constexpr std::size_t value = sizeof(T); }; TEST_CASE("Meta") { SECTION("If") { TEST(REQUIRE, is_same_v, int>); TEST(REQUIRE, is_same_v, char>); } SECTION("accumulate") { using E = pfor::Pack<>; using T = pfor::Pack; std::size_t esize = pfor::accumulate(0, std::plus{}); std::size_t tsize = pfor::accumulate(1, std::multiplies{}); REQUIRE(esize == 0); REQUIRE(tsize == sizeof(char)*sizeof(int)*sizeof(float)); } SECTION("GCD") { pfor::IntToType a; // ensure gcd can be computed at compile-time REQUIRE(pfor::gcd(5, 0) == 5); REQUIRE(pfor::gcd(9, 0) == 9); REQUIRE(pfor::gcd(-21, 9) == 3); REQUIRE(pfor::gcd(2*3*7*11*17, 11*19*23) == 11); REQUIRE(pfor::gcd(2*3*7*11*17*23, -11*19*23) == 11*23); } }