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

summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-09-27 18:30:31 +0200
committerMartin Hořeňovský2021-09-27 18:41:17 +0200
commit21b99d6f589090983136bf764514261dc863ed9a (patch)
treec5a6f5990179c0e4eecb6adbc90a7e7464fca22b /tests
parentd42e7a23a0ca942e73b7065a1fbf28b6b2a817ce (diff)
downloadcatch3-21b99d6f589090983136bf764514261dc863ed9a.tar.gz
Add StringRef::compare for three way comparison
Diffstat (limited to 'tests')
-rw-r--r--tests/SelfTest/Baselines/automake.sw.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/compact.sw.approved.txt10
-rw-r--r--tests/SelfTest/Baselines/console.std.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/console.sw.approved.txt68
-rw-r--r--tests/SelfTest/Baselines/junit.sw.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt2
-rw-r--r--tests/SelfTest/Baselines/tap.sw.approved.txt22
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.approved.txt2
-rw-r--r--tests/SelfTest/Baselines/xml.sw.approved.txt93
-rw-r--r--tests/SelfTest/IntrospectiveTests/String.tests.cpp27
10 files changed, 225 insertions, 8 deletions
diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt
index 7b401531..54d94cc2 100644
--- a/tests/SelfTest/Baselines/automake.sw.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.approved.txt
@@ -207,6 +207,7 @@ Message from section two
:test-result: PASS String matchers
:test-result: PASS StringRef
:test-result: PASS StringRef at compilation time
+:test-result: PASS StringRef::compare
:test-result: PASS Stringifying char arrays with statically known sizes - char
:test-result: PASS Stringifying char arrays with statically known sizes - signed char
:test-result: PASS Stringifying char arrays with statically known sizes - unsigned char
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index 1813ff3c..8b3df2ac 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -1537,6 +1537,16 @@ String.tests.cpp:<line number>: passed: with 1 message: '!(sr1.empty())'
String.tests.cpp:<line number>: passed: with 1 message: 'sr1.size() == 3'
String.tests.cpp:<line number>: passed: with 1 message: 'sr2.empty()'
String.tests.cpp:<line number>: passed: with 1 message: 'sr2.size() == 0'
+String.tests.cpp:<line number>: passed: sr1.compare(sr2) < 0 for: -1 < 0
+String.tests.cpp:<line number>: passed: sr2.compare(sr1) > 0 for: 1 > 0
+String.tests.cpp:<line number>: passed: sr1.compare(sr3) == 0 for: 0 == 0
+String.tests.cpp:<line number>: passed: sr3.compare(sr1) == 0 for: 0 == 0
+String.tests.cpp:<line number>: passed: sr1.compare(sr2) < 0 for: -1 < 0
+String.tests.cpp:<line number>: passed: sr2.compare(sr1) > 0 for: 1 > 0
+String.tests.cpp:<line number>: passed: sr1.compare(sr3) > 0 for: 3 > 0
+String.tests.cpp:<line number>: passed: sr2.compare(sr3) > 0 for: 3 > 0
+String.tests.cpp:<line number>: passed: sr3.compare(sr1) < 0 for: -3 < 0
+String.tests.cpp:<line number>: passed: sr3.compare(sr2) < 0 for: -3 < 0
ToString.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc""
ToString.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( no_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc""
ToString.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc""
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index 13b39435..a8a8fcb4 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -1386,6 +1386,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
-test cases: 369 | 293 passed | 70 failed | 6 failed as expected
-assertions: 2106 | 1954 passed | 129 failed | 23 failed as expected
+test cases: 370 | 294 passed | 70 failed | 6 failed as expected
+assertions: 2116 | 1964 passed | 129 failed | 23 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index ba1d14c9..12ca8ad7 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -10907,6 +10907,70 @@ with message:
sr2.size() == 0
-------------------------------------------------------------------------------
+StringRef::compare
+ Same length on both sides
+-------------------------------------------------------------------------------
+String.tests.cpp:<line number>
+...............................................................................
+
+String.tests.cpp:<line number>: PASSED:
+ REQUIRE( sr1.compare(sr2) < 0 )
+with expansion:
+ -1 < 0
+
+String.tests.cpp:<line number>: PASSED:
+ REQUIRE( sr2.compare(sr1) > 0 )
+with expansion:
+ 1 > 0
+
+String.tests.cpp:<line number>: PASSED:
+ REQUIRE( sr1.compare(sr3) == 0 )
+with expansion:
+ 0 == 0
+
+String.tests.cpp:<line number>: PASSED:
+ REQUIRE( sr3.compare(sr1) == 0 )
+with expansion:
+ 0 == 0
+
+-------------------------------------------------------------------------------
+StringRef::compare
+ Different lengths
+-------------------------------------------------------------------------------
+String.tests.cpp:<line number>
+...............................................................................
+
+String.tests.cpp:<line number>: PASSED:
+ REQUIRE( sr1.compare(sr2) < 0 )
+with expansion:
+ -1 < 0
+
+String.tests.cpp:<line number>: PASSED:
+ REQUIRE( sr2.compare(sr1) > 0 )
+with expansion:
+ 1 > 0
+
+String.tests.cpp:<line number>: PASSED:
+ REQUIRE( sr1.compare(sr3) > 0 )
+with expansion:
+ 3 > 0
+
+String.tests.cpp:<line number>: PASSED:
+ REQUIRE( sr2.compare(sr3) > 0 )
+with expansion:
+ 3 > 0
+
+String.tests.cpp:<line number>: PASSED:
+ REQUIRE( sr3.compare(sr1) < 0 )
+with expansion:
+ -3 < 0
+
+String.tests.cpp:<line number>: PASSED:
+ REQUIRE( sr3.compare(sr2) < 0 )
+with expansion:
+ -3 < 0
+
+-------------------------------------------------------------------------------
Stringifying char arrays with statically known sizes - char
-------------------------------------------------------------------------------
ToString.tests.cpp:<line number>
@@ -16954,6 +17018,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
-test cases: 369 | 277 passed | 86 failed | 6 failed as expected
-assertions: 2123 | 1954 passed | 146 failed | 23 failed as expected
+test cases: 370 | 278 passed | 86 failed | 6 failed as expected
+assertions: 2133 | 1964 passed | 146 failed | 23 failed as expected
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index f6285201..57225235 100644
--- a/tests/SelfTest/Baselines/junit.sw.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
- <testsuite name="<exe-name>" errors="17" failures="129" tests="2123" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="17" failures="129" tests="2133" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
<property name="random-seed" value="1"/>
@@ -1196,6 +1196,8 @@ Matchers.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="StringRef/StringRef + StringRef" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="StringRef at compilation time/Simple constructors" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="StringRef at compilation time/UDL construction" time="{duration}" status="run"/>
+ <testcase classname="<exe-name>.global" name="StringRef::compare/Same length on both sides" time="{duration}" status="run"/>
+ <testcase classname="<exe-name>.global" name="StringRef::compare/Different lengths" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Stringifying char arrays with statically known sizes - char" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Stringifying char arrays with statically known sizes - signed char" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Stringifying char arrays with statically known sizes - unsigned char" time="{duration}" status="run"/>
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index c95948c3..6c43b6b3 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -204,6 +204,8 @@
<testCase name="StringRef/StringRef + StringRef" duration="{duration}"/>
<testCase name="StringRef at compilation time/Simple constructors" duration="{duration}"/>
<testCase name="StringRef at compilation time/UDL construction" duration="{duration}"/>
+ <testCase name="StringRef::compare/Same length on both sides" duration="{duration}"/>
+ <testCase name="StringRef::compare/Different lengths" duration="{duration}"/>
</file>
<file path="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp">
<testCase name="Trim strings" duration="{duration}"/>
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index a82febac..6583d673 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -2753,6 +2753,26 @@ ok {test-number} - with 1 message: 'sr1.size() == 3'
ok {test-number} - with 1 message: 'sr2.empty()'
# StringRef at compilation time
ok {test-number} - with 1 message: 'sr2.size() == 0'
+# StringRef::compare
+ok {test-number} - sr1.compare(sr2) < 0 for: -1 < 0
+# StringRef::compare
+ok {test-number} - sr2.compare(sr1) > 0 for: 1 > 0
+# StringRef::compare
+ok {test-number} - sr1.compare(sr3) == 0 for: 0 == 0
+# StringRef::compare
+ok {test-number} - sr3.compare(sr1) == 0 for: 0 == 0
+# StringRef::compare
+ok {test-number} - sr1.compare(sr2) < 0 for: -1 < 0
+# StringRef::compare
+ok {test-number} - sr2.compare(sr1) > 0 for: 1 > 0
+# StringRef::compare
+ok {test-number} - sr1.compare(sr3) > 0 for: 3 > 0
+# StringRef::compare
+ok {test-number} - sr2.compare(sr3) > 0 for: 3 > 0
+# StringRef::compare
+ok {test-number} - sr3.compare(sr1) < 0 for: -3 < 0
+# StringRef::compare
+ok {test-number} - sr3.compare(sr2) < 0 for: -3 < 0
# Stringifying char arrays with statically known sizes - char
ok {test-number} - ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc""
# Stringifying char arrays with statically known sizes - char
@@ -4248,5 +4268,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
-1..2123
+1..2133
diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt
index 3867ec4a..d61c69df 100644
--- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt
+++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt
@@ -514,6 +514,8 @@ Matchers.tests.cpp:<line number>|nexpression failed|n CHECK_THAT( testStringFor
##teamcity[testFinished name='StringRef' duration="{duration}"]
##teamcity[testStarted name='StringRef at compilation time']
##teamcity[testFinished name='StringRef at compilation time' duration="{duration}"]
+##teamcity[testStarted name='StringRef::compare']
+##teamcity[testFinished name='StringRef::compare' duration="{duration}"]
##teamcity[testStarted name='Stringifying char arrays with statically known sizes - char']
##teamcity[testFinished name='Stringifying char arrays with statically known sizes - char' duration="{duration}"]
##teamcity[testStarted name='Stringifying char arrays with statically known sizes - signed char']
diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt
index 917010be..a20b2ffb 100644
--- a/tests/SelfTest/Baselines/xml.sw.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.approved.txt
@@ -12945,6 +12945,95 @@ Message from section two
</Section>
<OverallResult success="true"/>
</TestCase>
+ <TestCase name="StringRef::compare" tags="[StringRef][Strings]" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Section name="Same length on both sides" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Original>
+ sr1.compare(sr2) &lt; 0
+ </Original>
+ <Expanded>
+ -1 &lt; 0
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Original>
+ sr2.compare(sr1) > 0
+ </Original>
+ <Expanded>
+ 1 > 0
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Original>
+ sr1.compare(sr3) == 0
+ </Original>
+ <Expanded>
+ 0 == 0
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Original>
+ sr3.compare(sr1) == 0
+ </Original>
+ <Expanded>
+ 0 == 0
+ </Expanded>
+ </Expression>
+ <OverallResults successes="4" failures="0" expectedFailures="0"/>
+ </Section>
+ <Section name="Different lengths" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Original>
+ sr1.compare(sr2) &lt; 0
+ </Original>
+ <Expanded>
+ -1 &lt; 0
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Original>
+ sr2.compare(sr1) > 0
+ </Original>
+ <Expanded>
+ 1 > 0
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Original>
+ sr1.compare(sr3) > 0
+ </Original>
+ <Expanded>
+ 3 > 0
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Original>
+ sr2.compare(sr3) > 0
+ </Original>
+ <Expanded>
+ 3 > 0
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Original>
+ sr3.compare(sr1) &lt; 0
+ </Original>
+ <Expanded>
+ -3 &lt; 0
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
+ <Original>
+ sr3.compare(sr2) &lt; 0
+ </Original>
+ <Expanded>
+ -3 &lt; 0
+ </Expanded>
+ </Expression>
+ <OverallResults successes="6" failures="0" expectedFailures="0"/>
+ </Section>
+ <OverallResult success="true"/>
+ </TestCase>
<TestCase name="Stringifying char arrays with statically known sizes - char" tags="[toString]" filename="tests/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
<Original>
@@ -19953,6 +20042,6 @@ loose text artifact
</Section>
<OverallResult success="true"/>
</TestCase>
- <OverallResults successes="1954" failures="146" expectedFailures="23"/>
- <OverallResultsCases successes="277" failures="86" expectedFailures="6"/>
+ <OverallResults successes="1964" failures="146" expectedFailures="23"/>
+ <OverallResultsCases successes="278" failures="86" expectedFailures="6"/>
</Catch2TestRun>
diff --git a/tests/SelfTest/IntrospectiveTests/String.tests.cpp b/tests/SelfTest/IntrospectiveTests/String.tests.cpp
index 4b9cc0e3..c44b7230 100644
--- a/tests/SelfTest/IntrospectiveTests/String.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/String.tests.cpp
@@ -165,3 +165,30 @@ TEST_CASE("StringRef at compilation time", "[Strings][StringRef][constexpr]") {
STATIC_REQUIRE(sr2.size() == 0);
}
}
+
+TEST_CASE("StringRef::compare", "[Strings][StringRef]") {
+ using Catch::StringRef;
+
+ SECTION("Same length on both sides") {
+ StringRef sr1("abcdc");
+ StringRef sr2("abcdd");
+ StringRef sr3("abcdc");
+
+ REQUIRE(sr1.compare(sr2) < 0);
+ REQUIRE(sr2.compare(sr1) > 0);
+ REQUIRE(sr1.compare(sr3) == 0);
+ REQUIRE(sr3.compare(sr1) == 0);
+ }
+ SECTION("Different lengths") {
+ StringRef sr1("def");
+ StringRef sr2("deff");
+ StringRef sr3("ab");
+
+ REQUIRE(sr1.compare(sr2) < 0);
+ REQUIRE(sr2.compare(sr1) > 0);
+ REQUIRE(sr1.compare(sr3) > 0);
+ REQUIRE(sr2.compare(sr3) > 0);
+ REQUIRE(sr3.compare(sr1) < 0);
+ REQUIRE(sr3.compare(sr2) < 0);
+ }
+}