Improve error messages for TEST_CASE tag parsing errors

Also removes a duplicated test case checking for empty tag error.

Related to #2650
This commit is contained in:
Martin Hořeňovský
2023-05-20 19:25:00 +02:00
parent 06c0e1cfab
commit a153fce724
19 changed files with 54 additions and 81 deletions

View File

@@ -98,7 +98,20 @@ TEST_CASE( "Test case with identical tags keeps just one", "[tags]" ) {
REQUIRE( testCase.tags[0] == Tag( "tag1" ) );
}
TEST_CASE( "Empty tag is not allowed" ) {
REQUIRE_THROWS( Catch::TestCaseInfo(
"", { "fake test name", "[]" }, dummySourceLineInfo ) );
TEST_CASE("Mismatched square brackets in tags are caught and reported",
"[tags][approvals]") {
using Catch::TestCaseInfo;
using Catch::Matchers::ContainsSubstring;
REQUIRE_THROWS_WITH( TestCaseInfo( "",
{ "test with unclosed tag", "[abc" },
dummySourceLineInfo ),
ContainsSubstring("registering test case 'test with unclosed tag'") );
REQUIRE_THROWS_WITH( TestCaseInfo( "",
{ "test with nested tags", "[abc[def]]" },
dummySourceLineInfo ),
ContainsSubstring("registering test case 'test with nested tags'") );
REQUIRE_THROWS_WITH( TestCaseInfo( "",
{ "test with superfluous close tags", "[abc][def]]" },
dummySourceLineInfo ),
ContainsSubstring("registering test case 'test with superfluous close tags'") );
}