From 3634092bf211968f9b525e50e3f24d2964727dbf Mon Sep 17 00:00:00 2001 From: Neargye Date: Sat, 1 Sep 2018 22:19:33 +0500 Subject: [PATCH] fix test --- include/nameof.hpp | 2 +- test/test.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index bde5e31..f411395 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -385,7 +385,7 @@ template struct NameofEnumImpl { NAMEOF_CONSTEXPR nameof::cstring operator()(T value) const { return (static_cast(value) - I == 0) - ? NameofEnumImpl2() + ? NameofEnumImpl2() : (static_cast(value) >= 0) ? NameofEnumImpl{}(value) : NameofEnumImpl{}(value); diff --git a/test/test.cpp b/test/test.cpp index 5e7f53e..49c72b9 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -70,7 +70,7 @@ struct Long { enum class Color { RED = -1, GREEN, BLUE }; -enum Directions { Up, Down, Right, Left}; +enum Directions : int { Up, Down, Right, Left}; SomeStruct struct_var; Long othervar; @@ -145,17 +145,17 @@ TEST_CASE("constexpr") { REQUIRE(cx6 == "__cplusplus"); } +#if defined(NAMEOF_HAS_CONSTEXPR) SECTION("NAMEOF_ENUM") { constexpr auto cx = NAMEOF_ENUM(color); -#if defined(__clang__) || defined(_MSC_VER) +# if defined(__clang__) || defined(_MSC_VER) static_assert(cx == "RED", ""); REQUIRE(cx == "RED"); -#elif defined(__GNUC__) +# elif defined(__GNUC__) REQUIRE(cx == "(const Color)-1"); -#endif +# endif } -#if defined(NAMEOF_TYPE_HAS_CONSTEXPR) SECTION("NAMEOF_TYPE") { constexpr auto cx = NAMEOF_TYPE(ptr_c); # if defined(__clang__)