#include #include TEST_CASE("compile-time named bools", "[utility]") { using namespace stdx::literals; STATIC_REQUIRE("variable"_b); STATIC_REQUIRE(not(not "variable"_b)); STATIC_REQUIRE("variable"_true); STATIC_REQUIRE(not "variable"_false); } TEST_CASE("decimal units", "[units]") { using namespace stdx::literals; STATIC_REQUIRE(1_k == 1'000ull); STATIC_REQUIRE(1_M == 1'000'000ull); STATIC_REQUIRE(1_G == 1'000'000'000ull); } TEST_CASE("binary units", "[units]") { using namespace stdx::literals; STATIC_REQUIRE(1_ki == 1'024ull); STATIC_REQUIRE(1_Mi == 1'024ull * 1'024ull); STATIC_REQUIRE(1_Gi == 1'024ull * 1'024ull * 1'024ull); } TEST_CASE("compile-time named small indices", "[units]") { using namespace stdx::literals; STATIC_REQUIRE(std::is_same_v>); STATIC_REQUIRE("index"_0 == 0u); STATIC_REQUIRE("index"_1 == 1u); STATIC_REQUIRE("index"_2 == 2u); STATIC_REQUIRE("index"_3 == 3u); STATIC_REQUIRE("index"_4 == 4u); STATIC_REQUIRE("index"_5 == 5u); STATIC_REQUIRE("index"_6 == 6u); STATIC_REQUIRE("index"_7 == 7u); STATIC_REQUIRE("index"_8 == 8u); STATIC_REQUIRE("index"_9 == 9u); } TEST_CASE("compile-time constant", "[units]") { STATIC_REQUIRE(std::is_same_v), std::integral_constant const>); STATIC_REQUIRE( std::is_same_v), std::integral_constant const>); } TEST_CASE("compile-time literal (decimal)", "[units]") { using namespace stdx::literals; STATIC_REQUIRE(std::is_same_v>); } TEST_CASE("compile-time literal supports digit separators", "[units]") { using namespace stdx::literals; STATIC_REQUIRE( std::is_same_v>); } TEST_CASE("compile-time literal (octal)", "[units]") { using namespace stdx::literals; STATIC_REQUIRE(std::is_same_v>); STATIC_REQUIRE(std::is_same_v>); } TEST_CASE("compile-time literal (binary)", "[units]") { using namespace stdx::literals; STATIC_REQUIRE(std::is_same_v>); STATIC_REQUIRE(std::is_same_v>); } TEST_CASE("compile-time literal (hex)", "[units]") { using namespace stdx::literals; STATIC_REQUIRE(std::is_same_v>); STATIC_REQUIRE(std::is_same_v>); STATIC_REQUIRE(std::is_same_v>); } namespace { enum UnscopedEnum { Value3 = 3 }; enum struct ScopedEnum : char { Value5 = 5 }; } // namespace TEST_CASE("compile-time enum constant", "[units]") { using namespace stdx; STATIC_REQUIRE( std::is_same_v), std::integral_constant const>); STATIC_REQUIRE( std::is_same_v< decltype(_c), std::integral_constant const>); }