1
0
Fork 0
mirror of https://github.com/Neargye/magic_enum.git synced 2026-01-09 23:34:23 +00:00

Discontinouos uint8_t test + fix (#182)

This commit is contained in:
Bela Schaum 2022-04-17 21:40:54 +02:00 committed by GitHub
parent 88e239645d
commit ed09da9f36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -769,7 +769,7 @@ constexpr auto calculate_cases(std::size_t Page) noexcept {
} }
auto it = result.begin(); auto it = result.begin();
for (auto last_value = (std::numeric_limits<switch_t>::min)(); fill != result.end(); *fill++ = last_value) { for (auto last_value = (std::numeric_limits<switch_t>::min)(); fill != result.end(); *fill++ = last_value++) {
while (last_value == *it) { while (last_value == *it) {
++last_value, ++it; ++last_value, ++it;
} }

View file

@ -84,7 +84,7 @@ struct magic_enum::customize::enum_range<number> {
enum class MaxUsedAsInvalid : std::uint8_t { enum class MaxUsedAsInvalid : std::uint8_t {
ONE, ONE,
TWO, TWO = 63,
INVALID = std::numeric_limits<std::uint8_t>::max() INVALID = std::numeric_limits<std::uint8_t>::max()
}; };
template <> template <>
@ -582,6 +582,8 @@ TEST_CASE("enum_name") {
REQUIRE(nt_name == "three"); REQUIRE(nt_name == "three");
REQUIRE(enum_name(number::four).empty()); REQUIRE(enum_name(number::four).empty());
REQUIRE(enum_name(static_cast<number>(0)).empty()); REQUIRE(enum_name(static_cast<number>(0)).empty());
REQUIRE(enum_name(MaxUsedAsInvalid::ONE) == "ONE");
} }
SECTION("static storage") { SECTION("static storage") {
@ -989,7 +991,7 @@ TEST_CASE("extrema") {
REQUIRE(magic_enum::detail::max_v<Binary> == true); REQUIRE(magic_enum::detail::max_v<Binary> == true);
REQUIRE(magic_enum::detail::reflected_max_v<MaxUsedAsInvalid, false> == 64); REQUIRE(magic_enum::detail::reflected_max_v<MaxUsedAsInvalid, false> == 64);
REQUIRE(magic_enum::detail::max_v<MaxUsedAsInvalid> == 1); REQUIRE(magic_enum::detail::max_v<MaxUsedAsInvalid> == 63);
} }
} }