mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-10 23:44:29 +00:00
wip
This commit is contained in:
parent
619164687f
commit
8f31ad7cfa
4 changed files with 39 additions and 11 deletions
|
|
@ -27,6 +27,10 @@
|
|||
#define MAGIC_ENUM_RANGE_MAX 120
|
||||
#include <magic_enum.hpp>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1920 || defined(__clang__) && __clang_major__ >= 5 || defined(__GNUC__) && __GNUC__ >= 9
|
||||
# define MAGIC_ENUM_SUPPORTED_ALIASES
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <cctype>
|
||||
#include <string_view>
|
||||
|
|
@ -44,9 +48,7 @@ enum number : unsigned long {
|
|||
three = 300,
|
||||
four = 400,
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1920
|
||||
// Aliases won't work on vs2017.
|
||||
|
||||
#if defined(MAGIC_ENUM_SUPPORTED_ALIASES)
|
||||
_1 = one,
|
||||
_2 = two,
|
||||
_3 = three,
|
||||
|
|
@ -260,7 +262,7 @@ TEST_CASE("enum_contains") {
|
|||
constexpr auto cr = "RED";
|
||||
REQUIRE(enum_contains<Color>(cr));
|
||||
REQUIRE(enum_contains<Color&>("GREEN"));
|
||||
REQUIRE(enum_contains<Color>("BLUE"));
|
||||
REQUIRE(enum_contains<Color>("blue", [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }));
|
||||
REQUIRE_FALSE(enum_contains<Color>("None"));
|
||||
|
||||
constexpr auto no = std::string_view{"one"};
|
||||
|
|
@ -573,16 +575,16 @@ TEST_CASE("type_traits") {
|
|||
REQUIRE_FALSE(is_scoped_enum_v<number>);
|
||||
}
|
||||
|
||||
|
||||
/* TODO: https://github.com/Neargye/nameof/issues/22
|
||||
TEST_CASE("enum_type_name") {
|
||||
REQUIRE(enum_type_name<Color&>() == "Color");
|
||||
REQUIRE(enum_type_name<Numbers>() == "Numbers");
|
||||
REQUIRE(enum_type_name<Directions&>() == "Directions");
|
||||
REQUIRE(enum_type_name<number>() == "number");
|
||||
}
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1920
|
||||
// Aliases won't work on vs2017.
|
||||
#if defined(MAGIC_ENUM_SUPPORTED_ALIASES)
|
||||
TEST_CASE("aliases") {
|
||||
REQUIRE(enum_count<number>() == 3);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue