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

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-10-27 17:10:28 +0200
committerMartin Hořeňovský2022-10-27 18:23:59 +0200
commite19ed221bde6b8d8a1a62a71ed942c238ae345a7 (patch)
tree954ce5e9334d0dd588d12d6290756896897d92a2 /tests/SelfTest
parentc6dfeb5e7dc175ca4765e884414dab52736cde9e (diff)
downloadcatch3-e19ed221bde6b8d8a1a62a71ed942c238ae345a7.tar.gz
Provide round-tripping serialization for TestSpec
Diffstat (limited to 'tests/SelfTest')
-rw-r--r--tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp b/tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp
index 99ad6073..f692ae61 100644
--- a/tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp
@@ -325,3 +325,40 @@ TEST_CASE("#1912 -- test spec parser handles escaping", "[command-line][test-spe
REQUIRE(spec.matches(*fakeTestCase(R"(spec \ char)")));
}
}
+
+TEST_CASE("Test spec serialization is round-trippable", "[test-spec][serialization][approvals]") {
+ using Catch::parseTestSpec;
+ using Catch::TestSpec;
+
+ auto serializedTestSpec = []( std::string const& spec ) {
+ Catch::ReusableStringStream sstr;
+ sstr << parseTestSpec( spec );
+ return sstr.str();
+ };
+
+ SECTION("Spaces are normalized") {
+ CHECK( serializedTestSpec( "[abc][def]" ) == "[abc] [def]" );
+ CHECK( serializedTestSpec( "[def] [abc]" ) == "[def] [abc]" );
+ CHECK( serializedTestSpec( "[def] [abc]" ) == "[def] [abc]" );
+ }
+ SECTION("Output is order dependent") {
+ CHECK( serializedTestSpec( "[abc][def]" ) == "[abc] [def]" );
+ CHECK( serializedTestSpec( "[def][abc]" ) == "[def] [abc]" );
+ }
+ SECTION("Multiple disjunct filters") {
+ CHECK( serializedTestSpec( "[abc],[def]" ) == "[abc],[def]" );
+ CHECK( serializedTestSpec( "[def],[abc],[idkfa]" ) == "[def],[abc],[idkfa]" );
+ }
+ SECTION("Test names are enclosed in string") {
+ CHECK( serializedTestSpec( "Some test" ) == "\"Some test\"" );
+ CHECK( serializedTestSpec( "*Some test" ) == "\"*Some test\"" );
+ CHECK( serializedTestSpec( "* Some test" ) == "\"* Some test\"" );
+ CHECK( serializedTestSpec( "* Some test *" ) == "\"* Some test *\"" );
+ }
+ SECTION( "Mixing test names and tags" ) {
+ CHECK( serializedTestSpec( "some test[abcd]" ) ==
+ "\"some test\" [abcd]" );
+ CHECK( serializedTestSpec( "[ab]some test[cd]" ) ==
+ "[ab] \"some test\" [cd]" );
+ }
+}