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

summaryrefslogtreecommitdiffhomepage
path: root/projects
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-11-07 12:39:07 +0100
committerMartin Hořeňovský2019-11-14 10:53:12 +0100
commitd36c15c3caf96c2e751f4ad83a386c1fd047c2f6 (patch)
treecba3faef17447ccfd3a2c9a7e751f8a52e2ae226 /projects
parent302e2c0b06f131199b97ad33bdebacc359782ff0 (diff)
downloadcatch3-d36c15c3caf96c2e751f4ad83a386c1fd047c2f6.tar.gz
Store tags in one big pre-allocated string and only work with refs
This should decrease the number of allocations before main is entered significantly, but complicates the code somewhat in return. Assuming I used `massif` right, doing just `SelfTest --list-tests` went from 929 allocations at "Remove gcc-4.9 from the travis builds" (2 commits up), to 614 allocations with this commit.
Diffstat (limited to 'projects')
-rw-r--r--projects/SelfTest/Baselines/compact.sw.approved.txt2
-rw-r--r--projects/SelfTest/Baselines/console.sw.approved.txt4
-rw-r--r--projects/SelfTest/Baselines/xml.sw.approved.txt20
-rw-r--r--projects/SelfTest/IntrospectiveTests/Tag.tests.cpp8
4 files changed, 20 insertions, 14 deletions
diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt
index d7dfb5cc..6853df4e 100644
--- a/projects/SelfTest/Baselines/compact.sw.approved.txt
+++ b/projects/SelfTest/Baselines/compact.sw.approved.txt
@@ -1662,7 +1662,7 @@ StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(s, "'", "|'")
StringManip.tests.cpp:<line number>: passed: s == "didn|'t" for: "didn|'t" == "didn|'t"
Misc.tests.cpp:<line number>: failed: false with 1 message: '3'
Message.tests.cpp:<line number>: failed: false with 2 messages: 'hi' and 'i := 7'
-Tag.tests.cpp:<line number>: passed: testcase->tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")) for: { ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." )
+Tag.tests.cpp:<line number>: passed: tags, Catch::VectorContains("magic-tag"_catch_sr) && Catch::VectorContains("."_catch_sr) for: { ., magic-tag } ( Contains: magic-tag and Contains: . )
StringManip.tests.cpp:<line number>: passed: splitStringRef("", ','), Equals(std::vector<StringRef>()) for: { } Equals: { }
StringManip.tests.cpp:<line number>: passed: splitStringRef("abc", ','), Equals(std::vector<StringRef>{"abc"}) for: { abc } Equals: { abc }
StringManip.tests.cpp:<line number>: passed: splitStringRef("abc,def", ','), Equals(std::vector<StringRef>{"abc", "def"}) for: { abc, def } Equals: { abc, def }
diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt
index 9ed692cf..e8259948 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -12341,9 +12341,9 @@ Tag.tests.cpp:<line number>
...............................................................................
Tag.tests.cpp:<line number>: PASSED:
- REQUIRE_THAT( testcase->tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")) )
+ REQUIRE_THAT( tags, Catch::VectorContains("magic-tag"_catch_sr) && Catch::VectorContains("."_catch_sr) )
with expansion:
- { ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." )
+ { ., magic-tag } ( Contains: magic-tag and Contains: . )
-------------------------------------------------------------------------------
splitString
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index effb76f4..d57f0b86 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -1730,7 +1730,7 @@ Nor would this
</Failure>
<OverallResult success="false"/>
</TestCase>
- <TestCase name="A failing expression with a non streamable type is still captured" tags="[.][Tricky][failing]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
+ <TestCase name="A failing expression with a non streamable type is still captured" tags="[.][failing][Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<Expression success="false" type="CHECK" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<Original>
&amp;o1 == &amp;o2
@@ -2510,7 +2510,7 @@ Nor would this
</Expression>
<OverallResult success="true"/>
</TestCase>
- <TestCase name="Comparing function pointers" tags="[Tricky][function pointer]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
+ <TestCase name="Comparing function pointers" tags="[function pointer][Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<Original>
a
@@ -10985,7 +10985,7 @@ Message from section two
</Section>
<OverallResult success="true"/>
</TestCase>
- <TestCase name="StringRef at compilation time" tags="[StringRef][Strings][constexpr]" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <TestCase name="StringRef at compilation time" tags="[constexpr][StringRef][Strings]" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Section name="Simple constructors" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<OverallResults successes="5" failures="0" expectedFailures="0"/>
</Section>
@@ -13709,13 +13709,13 @@ There is no extra whitespace here
<TestCase name="When unchecked exceptions are thrown, but caught, they do not affect the test" tags="[!throws]" filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" >
<OverallResult success="false"/>
</TestCase>
- <TestCase name="Where the LHS is not a simple value" tags="[.][Tricky][failing]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
+ <TestCase name="Where the LHS is not a simple value" tags="[.][failing][Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<Warning>
Uncomment the code in this test to check that it gives a sensible compiler error
</Warning>
<OverallResult success="false"/>
</TestCase>
- <TestCase name="Where there is more to the expression after the RHS" tags="[.][Tricky][failing]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
+ <TestCase name="Where there is more to the expression after the RHS" tags="[.][failing][Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<Warning>
Uncomment the code in this test to check that it gives a sensible compiler error
</Warning>
@@ -13724,7 +13724,7 @@ There is no extra whitespace here
<TestCase name="X/level/0/a" tags="[Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<OverallResult success="true"/>
</TestCase>
- <TestCase name="X/level/0/b" tags="[Tricky][fizz]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
+ <TestCase name="X/level/0/b" tags="[fizz][Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<OverallResult success="true"/>
</TestCase>
<TestCase name="X/level/1/a" tags="[Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
@@ -14504,7 +14504,7 @@ loose text artifact
</Expression>
<OverallResult success="true"/>
</TestCase>
- <TestCase name="parseEnums" tags="[Strings][enums]" filename="projects/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
+ <TestCase name="parseEnums" tags="[enums][Strings]" filename="projects/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
<Section name="No enums" filename="projects/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
<Original>
@@ -14861,10 +14861,10 @@ loose text artifact
<TestCase name="shortened hide tags are split apart" filename="projects/<exe-name>/IntrospectiveTests/Tag.tests.cpp" >
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/IntrospectiveTests/Tag.tests.cpp" >
<Original>
- testcase->tags, Catch::VectorContains(std::string("magic-tag")) &amp;&amp; Catch::VectorContains(std::string("."))
+ tags, Catch::VectorContains("magic-tag"_catch_sr) &amp;&amp; Catch::VectorContains("."_catch_sr)
</Original>
<Expanded>
- { ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." )
+ { ., magic-tag } ( Contains: magic-tag and Contains: . )
</Expanded>
</Expression>
<OverallResult success="true"/>
@@ -15050,7 +15050,7 @@ loose text artifact
</Expression>
<OverallResult success="true"/>
</TestCase>
- <TestCase name="string literals of different sizes can be compared" tags="[.][Tricky][failing]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
+ <TestCase name="string literals of different sizes can be compared" tags="[.][failing][Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<Expression success="false" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<Original>
std::string( "first" ) == "second"
diff --git a/projects/SelfTest/IntrospectiveTests/Tag.tests.cpp b/projects/SelfTest/IntrospectiveTests/Tag.tests.cpp
index 79657226..5120d8ed 100644
--- a/projects/SelfTest/IntrospectiveTests/Tag.tests.cpp
+++ b/projects/SelfTest/IntrospectiveTests/Tag.tests.cpp
@@ -42,6 +42,12 @@ TEST_CASE( "Tag alias can be registered against tag patterns" ) {
}
TEST_CASE("shortened hide tags are split apart") {
+ using Catch::StringRef;
auto testcase = Catch::makeTestCaseInfo("", {"fake test name", "[.magic-tag]"}, CATCH_INTERNAL_LINEINFO);
- REQUIRE_THAT(testcase->tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")));
+ // Transform ...
+ std::vector<StringRef> tags;
+ for (auto const& tag : testcase->tags) {
+ tags.push_back(tag.original);
+ }
+ REQUIRE_THAT(tags, Catch::VectorContains("magic-tag"_catch_sr) && Catch::VectorContains("."_catch_sr));
}