diff options
| author | Martin Hořeňovský | 2022-10-27 17:10:28 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-10-27 18:23:59 +0200 |
| commit | e19ed221bde6b8d8a1a62a71ed942c238ae345a7 (patch) | |
| tree | 954ce5e9334d0dd588d12d6290756896897d92a2 /tests/SelfTest | |
| parent | c6dfeb5e7dc175ca4765e884414dab52736cde9e (diff) | |
| download | catch3-e19ed221bde6b8d8a1a62a71ed942c238ae345a7.tar.gz | |
Provide round-tripping serialization for TestSpec
Diffstat (limited to 'tests/SelfTest')
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp | 37 |
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]" ); + } +} |