1515#include < magic_enum/magic_enum_switch.hpp>
1616#include < magic_enum/magic_enum_utility.hpp>
1717
18+ #if defined(MAGIC_ENUM_CALLING_CONVENTION) || defined(MAGIC_ENUM_VS_2017_WORKAROUND) || defined(MAGIC_ENUM_ARRAY_CONSTEXPR)
19+ # error Internal macro leaked from magic_enum.hpp.
20+ #endif
21+
1822#include " test_helpers.hpp"
1923
2024#include < array>
@@ -35,6 +39,14 @@ constexpr magic_enum::customize::customize_t magic_enum::customize::enum_name<Co
3539
3640enum class Numbers : int { one = 1 , two, three, many = 127 };
3741
42+ #if defined(MAGIC_ENUM_TEST_VS_2017_WORKAROUND)
43+ template <typename , typename >
44+ struct templated_scope {
45+ enum class Value { ONE , TWO };
46+ };
47+ using TemplatedValue = templated_scope<int , long >::Value;
48+ #endif
49+
3850enum Directions { Up = 85 , Down = -42 , Right = 120 , Left = -120 };
3951
4052enum number : unsigned long {
@@ -522,6 +534,10 @@ TEST_CASE("enum_count") {
522534
523535 constexpr auto s6 = enum_count<MaxUsedAsInvalid>();
524536 REQUIRE (s6 == 2 );
537+
538+ #if defined(MAGIC_ENUM_TEST_VS_2017_WORKAROUND)
539+ REQUIRE (enum_count<TemplatedValue>() == 2 );
540+ #endif
525541}
526542
527543enum lt1 { s1, loooooooooooooooooooong1 };
@@ -628,6 +644,9 @@ TEST_CASE("enum_name") {
628644 REQUIRE (enum_name (static_cast <number>(0 )).empty ());
629645
630646 REQUIRE (enum_name (MaxUsedAsInvalid::ONE ) == " ONE" );
647+ #if defined(MAGIC_ENUM_TEST_VS_2017_WORKAROUND)
648+ REQUIRE (enum_name (TemplatedValue::ONE ) == " ONE" );
649+ #endif
631650
632651 REQUIRE (enum_name (lt1::s1) == " s1" );
633652 REQUIRE (enum_name (lt1::loooooooooooooooooooong1) == " loooooooooooooooooooong1" );
@@ -1113,7 +1132,7 @@ TEST_CASE("extrema") {
11131132 REQUIRE (magic_enum::detail::reflected_min<Directions, as_common<>>() == MAGIC_ENUM_RANGE_MIN );
11141133 REQUIRE (magic_enum::detail::min_v<Directions, as_common<>> == -120 );
11151134
1116- REQUIRE (magic_enum::customize::enum_range<number>::min == 100 );
1135+ REQUIRE (static_cast < int >( magic_enum::customize::enum_range<number>::min) == 100 );
11171136 REQUIRE (magic_enum::detail::reflected_min<number, as_common<>>() == 100 );
11181137 REQUIRE (magic_enum::detail::min_v<number, as_common<>> == 100 );
11191138
@@ -1141,7 +1160,7 @@ TEST_CASE("extrema") {
11411160 REQUIRE (magic_enum::detail::reflected_max<Directions, as_common<>>() == MAGIC_ENUM_RANGE_MAX );
11421161 REQUIRE (magic_enum::detail::max_v<Directions, as_common<>> == 120 );
11431162
1144- REQUIRE (magic_enum::customize::enum_range<number>::max == 300 );
1163+ REQUIRE (static_cast < int >( magic_enum::customize::enum_range<number>::max) == 300 );
11451164 REQUIRE (magic_enum::detail::reflected_max<number, as_common<>>() == 300 );
11461165 REQUIRE (magic_enum::detail::max_v<number, as_common<>> == 300 );
11471166
@@ -1275,13 +1294,13 @@ TEST_CASE("enum_for_each") {
12751294 constexpr auto workResults = enum_for_each<Color>([](auto val) {
12761295 return DoWork<val>();
12771296 });
1278- REQUIRE (workResults == std::array<std::string_view, 3 >{" default" , " override" , " default" });
1297+ REQUIRE (workResults == std::array<std::string_view, 3 >{{ " default" , " override" , " default" } });
12791298
12801299 constexpr auto colorSequence = std::make_index_sequence<enum_count<Color>()>{};
12811300 static_assert (detail::all_invocable<Color, detail::subtype_v<Color>, LvalueOnlyForEach>(colorSequence));
12821301 static_assert (!detail::all_invocable<Color, detail::subtype_v<Color>, RvalueOnlyForEach>(colorSequence));
12831302 constexpr auto colorValues = enum_for_each<Color>(LvalueOnlyForEach{});
1284- REQUIRE (colorValues == std::array<int , 3 >{-12 , 7 , 15 });
1303+ REQUIRE (colorValues == std::array<int , 3 >{{ -12 , 7 , 15 } });
12851304 }
12861305
12871306 SUBCASE (" different return type" ) {
0 commit comments