fix test
This commit is contained in:
parent
bfacde30f2
commit
3634092bf2
2 changed files with 6 additions and 6 deletions
|
@ -385,7 +385,7 @@ template <typename T, int I = 0>
|
||||||
struct NameofEnumImpl {
|
struct NameofEnumImpl {
|
||||||
NAMEOF_CONSTEXPR nameof::cstring operator()(T value) const {
|
NAMEOF_CONSTEXPR nameof::cstring operator()(T value) const {
|
||||||
return (static_cast<int>(value) - I == 0)
|
return (static_cast<int>(value) - I == 0)
|
||||||
? NameofEnumImpl2<T, T(I)>()
|
? NameofEnumImpl2<T, T(0 + I)>()
|
||||||
: (static_cast<int>(value) >= 0)
|
: (static_cast<int>(value) >= 0)
|
||||||
? NameofEnumImpl<T, I + 1>{}(value)
|
? NameofEnumImpl<T, I + 1>{}(value)
|
||||||
: NameofEnumImpl<T, I - 1>{}(value);
|
: NameofEnumImpl<T, I - 1>{}(value);
|
||||||
|
|
|
@ -70,7 +70,7 @@ struct Long {
|
||||||
|
|
||||||
enum class Color { RED = -1, GREEN, BLUE };
|
enum class Color { RED = -1, GREEN, BLUE };
|
||||||
|
|
||||||
enum Directions { Up, Down, Right, Left};
|
enum Directions : int { Up, Down, Right, Left};
|
||||||
|
|
||||||
SomeStruct struct_var;
|
SomeStruct struct_var;
|
||||||
Long othervar;
|
Long othervar;
|
||||||
|
@ -145,17 +145,17 @@ TEST_CASE("constexpr") {
|
||||||
REQUIRE(cx6 == "__cplusplus");
|
REQUIRE(cx6 == "__cplusplus");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(NAMEOF_HAS_CONSTEXPR)
|
||||||
SECTION("NAMEOF_ENUM") {
|
SECTION("NAMEOF_ENUM") {
|
||||||
constexpr auto cx = NAMEOF_ENUM(color);
|
constexpr auto cx = NAMEOF_ENUM(color);
|
||||||
#if defined(__clang__) || defined(_MSC_VER)
|
# if defined(__clang__) || defined(_MSC_VER)
|
||||||
static_assert(cx == "RED", "");
|
static_assert(cx == "RED", "");
|
||||||
REQUIRE(cx == "RED");
|
REQUIRE(cx == "RED");
|
||||||
#elif defined(__GNUC__)
|
# elif defined(__GNUC__)
|
||||||
REQUIRE(cx == "(const Color)-1");
|
REQUIRE(cx == "(const Color)-1");
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(NAMEOF_TYPE_HAS_CONSTEXPR)
|
|
||||||
SECTION("NAMEOF_TYPE") {
|
SECTION("NAMEOF_TYPE") {
|
||||||
constexpr auto cx = NAMEOF_TYPE(ptr_c);
|
constexpr auto cx = NAMEOF_TYPE(ptr_c);
|
||||||
# if defined(__clang__)
|
# if defined(__clang__)
|
||||||
|
|
Loading…
Reference in a new issue