From 2144c44eecca22de023ce3f6486ef1df3d271688 Mon Sep 17 00:00:00 2001 From: terik23 Date: Sat, 6 Apr 2019 18:16:14 +0500 Subject: [PATCH] update test --- test/test.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/test/test.cpp b/test/test.cpp index 561f793..433f5af 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -26,6 +26,8 @@ #define MAGIC_ENUM_RANGE 120 #include +#include + enum class Color { RED = -12, GREEN = 7, BLUE = 15 }; enum class Numbers : char { one = 10, two = 20, three = 30 }; @@ -98,7 +100,7 @@ TEST_CASE("magic_enum::enum_from_string(name)") { REQUIRE(magic_enum::enum_from_string("one").value() == Numbers::one); REQUIRE(magic_enum::enum_from_string("two").value() == Numbers::two); - REQUIRE(magic_enum::enum_from_string("two").value() == Numbers::two); + REQUIRE(magic_enum::enum_from_string("three").value() == Numbers::three); REQUIRE(!magic_enum::enum_from_string("None").has_value()); REQUIRE(magic_enum::enum_from_string("Up").value() == Directions::Up); @@ -109,6 +111,34 @@ TEST_CASE("magic_enum::enum_from_string(name)") { REQUIRE(magic_enum::enum_from_string("one").value() == number::one); REQUIRE(magic_enum::enum_from_string("two").value() == number::two); - REQUIRE(magic_enum::enum_from_string("two").value() == number::two); + REQUIRE(magic_enum::enum_from_string("three").value() == number::three); REQUIRE(!magic_enum::enum_from_string("None").has_value()); } + +TEST_CASE("magic_enum::enum_sequence()") { + constexpr auto mge_s1 = magic_enum::enum_sequence(); + REQUIRE(mge_s1 == std::array{Color::RED, Color::GREEN, Color::BLUE}); + + constexpr auto mge_s2 = magic_enum::enum_sequence(); + REQUIRE(mge_s2 == std::array{Numbers::one, Numbers::two, Numbers::three}); + + constexpr auto mge_s3 = magic_enum::enum_sequence(); + REQUIRE(mge_s3 == std::array{Directions::Left, Directions::Down, Directions::Up, Directions::Right}); + + constexpr auto mge_s4 = magic_enum::enum_sequence(); + REQUIRE(mge_s4 == std::array{number::one, number::two, number::three}); +} + +TEST_CASE("magic_enum::enum_to_string_sequence()") { + constexpr auto mge_s1 = magic_enum::enum_to_string_sequence(); + REQUIRE(mge_s1 == std::array{"RED", "GREEN", "BLUE"}); + + constexpr auto mge_s2 = magic_enum::enum_to_string_sequence(); + REQUIRE(mge_s2 == std::array{"one", "two","three"}); + + constexpr auto mge_s3 = magic_enum::enum_to_string_sequence(); + REQUIRE(mge_s3 == std::array{"Left", "Down", "Up", "Right"}); + + constexpr auto mge_s4 = magic_enum::enum_to_string_sequence(); + REQUIRE(mge_s4 == std::array{"one", "two", "three"}); +}