Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-12-05 16:00:20 +0100
committerMartin Hořeňovský2019-12-05 16:00:20 +0100
commit0fea081ad1a678b379182930a3ec22a3e275dbf0 (patch)
tree3afa04ce6805d7a86e9c59f87ac68cb1d21eb8b2 /tests/SelfTest/IntrospectiveTests/ToString.tests.cpp
parent90e2549cecc2e886d563b7a88e752c9b4104f798 (diff)
downloadcatch3-0fea081ad1a678b379182930a3ec22a3e275dbf0.tar.gz
Move tests from projects/ to tests/
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests/ToString.tests.cpp')
-rw-r--r--tests/SelfTest/IntrospectiveTests/ToString.tests.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp b/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp
new file mode 100644
index 00000000..85e2c658
--- /dev/null
+++ b/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp
@@ -0,0 +1,42 @@
+#include <catch2/catch.hpp>
+
+#include <catch2/catch_enum_values_registry.h>
+
+enum class EnumClass3 { Value1, Value2, Value3, Value4 };
+
+
+TEST_CASE( "parseEnums", "[Strings][enums]" ) {
+ using namespace Catch::Matchers;
+ using Catch::Detail::parseEnums;
+
+ SECTION( "No enums" )
+ CHECK_THAT( parseEnums( "" ), Equals( std::vector<Catch::StringRef>{} ) );
+
+ SECTION( "One enum value" ) {
+ CHECK_THAT( parseEnums( "ClassName::EnumName::Value1" ),
+ Equals(std::vector<Catch::StringRef>{"Value1"} ) );
+ CHECK_THAT( parseEnums( "Value1" ),
+ Equals( std::vector<Catch::StringRef>{"Value1"} ) );
+ CHECK_THAT( parseEnums( "EnumName::Value1" ),
+ Equals(std::vector<Catch::StringRef>{"Value1"} ) );
+ }
+
+ SECTION( "Multiple enum values" ) {
+ CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ),
+ Equals( std::vector<Catch::StringRef>{"Value1", "Value2"} ) );
+ CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ),
+ Equals( std::vector<Catch::StringRef>{"Value1", "Value2", "Value3"} ) );
+ CHECK_THAT( parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ),
+ Equals( std::vector<Catch::StringRef>{"Value1", "Value2", "Value3"} ) );
+ }
+}
+
+TEST_CASE( "Directly creating an EnumInfo" ) {
+
+ using namespace Catch::Detail;
+ std::unique_ptr<EnumInfo> enumInfo = makeEnumInfo( "EnumName", "EnumName::Value1, EnumName::Value2", {0, 1} );
+
+ CHECK( enumInfo->lookup(0) == "Value1" );
+ CHECK( enumInfo->lookup(1) == "Value2" );
+ CHECK( enumInfo->lookup(3) == "{** unexpected enum value **}" );
+}