mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Disallow empty tags in test case specification
This commit is contained in:
parent
c9371865d4
commit
aee31d0620
@ -146,6 +146,7 @@ namespace Catch {
|
||||
// it over to backing storage and actually reference the
|
||||
// backing storage in the saved tags
|
||||
StringRef tagStr = originalTags.substr(tagStart+1, tagEnd - tagStart - 1);
|
||||
CATCH_ENFORCE(!tagStr.empty(), "Empty tags are not allowed");
|
||||
enforceNotReservedTag(tagStr, lineInfo);
|
||||
properties |= parseSpecialTag(tagStr);
|
||||
// When copying a tag to the backing storage, we need to
|
||||
|
@ -282,6 +282,7 @@ Message from section two
|
||||
:test-result: PASS classify_outliers
|
||||
:test-result: PASS comparisons between const int variables
|
||||
:test-result: PASS comparisons between int variables
|
||||
:test-result: PASS empty tags are not allowed
|
||||
:test-result: PASS erfc_inv
|
||||
:test-result: PASS estimate_clock_resolution
|
||||
:test-result: PASS even more nested SECTION tests
|
||||
|
@ -2065,6 +2065,7 @@ Condition.tests.cpp:<line number>: passed: long_var == unsigned_char_var for: 1
|
||||
Condition.tests.cpp:<line number>: passed: long_var == unsigned_short_var for: 1 == 1
|
||||
Condition.tests.cpp:<line number>: passed: long_var == unsigned_int_var for: 1 == 1
|
||||
Condition.tests.cpp:<line number>: passed: long_var == unsigned_long_var for: 1 == 1
|
||||
Tag.tests.cpp:<line number>: passed: Catch::TestCaseInfo("", { "test with an empty tag", "[]" }, dummySourceLineInfo)
|
||||
InternalBenchmark.tests.cpp:<line number>: passed: erfc_inv(1.103560) == Approx(-0.09203687623843015) for: -0.0920368762 == Approx( -0.0920368762 )
|
||||
InternalBenchmark.tests.cpp:<line number>: passed: erfc_inv(1.067400) == Approx(-0.05980291115763361) for: -0.0598029112 == Approx( -0.0598029112 )
|
||||
InternalBenchmark.tests.cpp:<line number>: passed: erfc_inv(0.050000) == Approx(1.38590382434967796) for: 1.3859038243 == Approx( 1.3859038243 )
|
||||
|
@ -1386,6 +1386,6 @@ due to unexpected exception with message:
|
||||
Why would you throw a std::string?
|
||||
|
||||
===============================================================================
|
||||
test cases: 364 | 288 passed | 70 failed | 6 failed as expected
|
||||
assertions: 2091 | 1939 passed | 129 failed | 23 failed as expected
|
||||
test cases: 365 | 289 passed | 70 failed | 6 failed as expected
|
||||
assertions: 2092 | 1940 passed | 129 failed | 23 failed as expected
|
||||
|
||||
|
@ -14597,6 +14597,15 @@ Condition.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
1 == 1
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
empty tags are not allowed
|
||||
-------------------------------------------------------------------------------
|
||||
Tag.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Tag.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THROWS( Catch::TestCaseInfo("", { "test with an empty tag", "[]" }, dummySourceLineInfo) )
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
erfc_inv
|
||||
-------------------------------------------------------------------------------
|
||||
@ -16843,6 +16852,6 @@ Misc.tests.cpp:<line number>
|
||||
Misc.tests.cpp:<line number>: PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 364 | 272 passed | 86 failed | 6 failed as expected
|
||||
assertions: 2108 | 1939 passed | 146 failed | 23 failed as expected
|
||||
test cases: 365 | 273 passed | 86 failed | 6 failed as expected
|
||||
assertions: 2109 | 1940 passed | 146 failed | 23 failed as expected
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuitesloose text artifact
|
||||
>
|
||||
<testsuite name="<exe-name>" errors="17" failures="130" tests="2109" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="17" failures="130" tests="2110" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<properties>
|
||||
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
|
||||
<property name="random-seed" value="1"/>
|
||||
@ -1548,6 +1548,7 @@ Misc.tests.cpp:<line number>
|
||||
<testcase classname="<exe-name>.global" name="classify_outliers/mixed" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="comparisons between const int variables" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="comparisons between int variables" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="empty tags are not allowed" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="erfc_inv" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="estimate_clock_resolution" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="even more nested SECTION tests/c/d (leaf)" time="{duration}" status="run"/>
|
||||
|
@ -216,6 +216,7 @@
|
||||
<file path="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp">
|
||||
<testCase name="Tag alias can be registered against tag patterns/The same tag alias can only be registered once" duration="{duration}"/>
|
||||
<testCase name="Tag alias can be registered against tag patterns/Tag aliases must be of the form [@name]" duration="{duration}"/>
|
||||
<testCase name="empty tags are not allowed" duration="{duration}"/>
|
||||
<testCase name="shortened hide tags are split apart" duration="{duration}"/>
|
||||
<testCase name="tags with dots in later positions are not parsed as hidden" duration="{duration}"/>
|
||||
</file>
|
||||
|
@ -3703,6 +3703,8 @@ ok {test-number} - long_var == unsigned_short_var for: 1 == 1
|
||||
ok {test-number} - long_var == unsigned_int_var for: 1 == 1
|
||||
# comparisons between int variables
|
||||
ok {test-number} - long_var == unsigned_long_var for: 1 == 1
|
||||
# empty tags are not allowed
|
||||
ok {test-number} - Catch::TestCaseInfo("", { "test with an empty tag", "[]" }, dummySourceLineInfo)
|
||||
# erfc_inv
|
||||
ok {test-number} - erfc_inv(1.103560) == Approx(-0.09203687623843015) for: -0.0920368762 == Approx( -0.0920368762 )
|
||||
# erfc_inv
|
||||
@ -4218,5 +4220,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
|
||||
ok {test-number} -
|
||||
# xmlentitycheck
|
||||
ok {test-number} -
|
||||
1..2108
|
||||
1..2109
|
||||
|
||||
|
@ -690,6 +690,8 @@ Misc.tests.cpp:<line number>|nexpression failed|n REQUIRE( testCheckedIf( false
|
||||
##teamcity[testFinished name='comparisons between const int variables' duration="{duration}"]
|
||||
##teamcity[testStarted name='comparisons between int variables']
|
||||
##teamcity[testFinished name='comparisons between int variables' duration="{duration}"]
|
||||
##teamcity[testStarted name='empty tags are not allowed']
|
||||
##teamcity[testFinished name='empty tags are not allowed' duration="{duration}"]
|
||||
##teamcity[testStarted name='erfc_inv']
|
||||
##teamcity[testFinished name='erfc_inv' duration="{duration}"]
|
||||
##teamcity[testStarted name='estimate_clock_resolution']
|
||||
|
@ -17257,6 +17257,17 @@ There is no extra whitespace here
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="empty tags are not allowed" tags="[tags]" filename="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_THROWS" filename="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp" >
|
||||
<Original>
|
||||
Catch::TestCaseInfo("", { "test with an empty tag", "[]" }, dummySourceLineInfo)
|
||||
</Original>
|
||||
<Expanded>
|
||||
Catch::TestCaseInfo("", { "test with an empty tag", "[]" }, dummySourceLineInfo)
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="erfc_inv" tags="[benchmark]" filename="tests/<exe-name>/IntrospectiveTests/InternalBenchmark.tests.cpp" >
|
||||
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/InternalBenchmark.tests.cpp" >
|
||||
<Original>
|
||||
@ -19815,9 +19826,9 @@ loose text artifact
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="1939" failures="147" expectedFailures="23"/>
|
||||
<OverallResultsCases successes="272" failures="86" expectedFailures="6"/>
|
||||
<OverallResults successes="1940" failures="147" expectedFailures="23"/>
|
||||
<OverallResultsCases successes="273" failures="86" expectedFailures="6"/>
|
||||
</Group>
|
||||
<OverallResults successes="1939" failures="146" expectedFailures="23"/>
|
||||
<OverallResultsCases successes="272" failures="86" expectedFailures="6"/>
|
||||
<OverallResults successes="1940" failures="146" expectedFailures="23"/>
|
||||
<OverallResultsCases successes="273" failures="86" expectedFailures="6"/>
|
||||
</Catch>
|
||||
|
@ -39,6 +39,9 @@ TEST_CASE( "Tag alias can be registered against tag patterns" ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Dummy line info for creating dummy test cases below
|
||||
constexpr Catch::SourceLineInfo dummySourceLineInfo = CATCH_INTERNAL_LINEINFO;
|
||||
|
||||
TEST_CASE("shortened hide tags are split apart", "[tags]") {
|
||||
using Catch::StringRef;
|
||||
using Catch::Matchers::VectorContains;
|
||||
@ -60,3 +63,9 @@ TEST_CASE("tags with dots in later positions are not parsed as hidden", "[tags]"
|
||||
REQUIRE(testcase->tags.size() == 1);
|
||||
REQUIRE(testcase->tags[0].original == "magic.tag"_catch_sr);
|
||||
}
|
||||
|
||||
TEST_CASE( "empty tags are not allowed", "[tags]" ) {
|
||||
REQUIRE_THROWS(
|
||||
Catch::TestCaseInfo("", { "test with an empty tag", "[]" }, dummySourceLineInfo)
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user