diff options
| author | Martin Jeřábek | 2021-03-08 14:57:59 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-12-29 20:20:29 +0100 |
| commit | 8711b63a0a7a64e0b0e65f41971a3a8c27ab7a44 (patch) | |
| tree | fab567daf6e6ab906997e73370bf34fc3f52f8fb | |
| parent | 72a09de2369b1d48954c2e8aa4c001b46c2e34c0 (diff) | |
| download | catch3-8711b63a0a7a64e0b0e65f41971a3a8c27ab7a44.tar.gz | |
Add tests for StringRef's copy operations being shallow
| -rw-r--r-- | tests/SelfTest/Baselines/compact.sw.approved.txt | 2 | ||||
| -rw-r--r-- | tests/SelfTest/Baselines/console.std.approved.txt | 2 | ||||
| -rw-r--r-- | tests/SelfTest/Baselines/console.sw.approved.txt | 26 | ||||
| -rw-r--r-- | tests/SelfTest/Baselines/junit.sw.approved.txt | 4 | ||||
| -rw-r--r-- | tests/SelfTest/Baselines/sonarqube.sw.approved.txt | 2 | ||||
| -rw-r--r-- | tests/SelfTest/Baselines/tap.sw.approved.txt | 6 | ||||
| -rw-r--r-- | tests/SelfTest/Baselines/xml.sw.approved.txt | 24 | ||||
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/String.tests.cpp | 12 |
8 files changed, 72 insertions, 6 deletions
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index fab13bf2..390e9a6e 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -1554,6 +1554,8 @@ String.tests.cpp:<line number>: passed: std::strcmp( rawChars, "hello" ) == 0 fo String.tests.cpp:<line number>: passed: s.data() == rawChars for: "hello" == "hello" String.tests.cpp:<line number>: passed: original == "original" String.tests.cpp:<line number>: passed: original.data() +String.tests.cpp:<line number>: passed: original.begin() == copy.begin() for: "original string" == "original string" +String.tests.cpp:<line number>: passed: original.begin() == copy.begin() for: "original string" == "original string" String.tests.cpp:<line number>: passed: ss.empty() == false for: false == false String.tests.cpp:<line number>: passed: ss.size() == 5 for: 5 == 5 String.tests.cpp:<line number>: passed: std::strncmp( ss.data(), "hello", 5 ) == 0 for: 0 == 0 diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index 92b8d9d9..fb5b2b28 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -1427,5 +1427,5 @@ due to unexpected exception with message: =============================================================================== test cases: 384 | 307 passed | 70 failed | 7 failed as expected -assertions: 2183 | 2027 passed | 129 failed | 27 failed as expected +assertions: 2185 | 2029 passed | 129 failed | 27 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index ac9f7eee..65baafcf 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -11081,6 +11081,30 @@ String.tests.cpp:<line number>: PASSED: ------------------------------------------------------------------------------- StringRef + Copy construction is shallow +------------------------------------------------------------------------------- +String.tests.cpp:<line number> +............................................................................... + +String.tests.cpp:<line number>: PASSED: + REQUIRE( original.begin() == copy.begin() ) +with expansion: + "original string" == "original string" + +------------------------------------------------------------------------------- +StringRef + Copy assignment is shallow +------------------------------------------------------------------------------- +String.tests.cpp:<line number> +............................................................................... + +String.tests.cpp:<line number>: PASSED: + REQUIRE( original.begin() == copy.begin() ) +with expansion: + "original string" == "original string" + +------------------------------------------------------------------------------- +StringRef Substrings zero-based substring ------------------------------------------------------------------------------- @@ -17541,5 +17565,5 @@ Misc.tests.cpp:<line number>: PASSED: =============================================================================== test cases: 384 | 291 passed | 86 failed | 7 failed as expected -assertions: 2200 | 2027 passed | 146 failed | 27 failed as expected +assertions: 2202 | 2029 passed | 146 failed | 27 failed as expected diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index a82176bd..9132e982 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="2200" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> + <testsuite name="<exe-name>" errors="17" failures="129" tests="2202" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <properties> <property name="random-seed" value="1"/> <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/> @@ -1235,6 +1235,8 @@ Matchers.tests.cpp:<line number> <testcase classname="<exe-name>.global" name="StringRef/Empty string" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="StringRef/From string literal" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="StringRef/From sub-string" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="StringRef/Copy construction is shallow" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="StringRef/Copy assignment is shallow" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="StringRef/Substrings/zero-based substring" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="StringRef/Substrings/non-zero-based substring" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="StringRef/Substrings/Pointer values of full refs should match" time="{duration}" status="run"/> diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index 72c2e692..ee0df2e4 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -210,6 +210,8 @@ <testCase name="StringRef/Empty string" duration="{duration}"/> <testCase name="StringRef/From string literal" duration="{duration}"/> <testCase name="StringRef/From sub-string" duration="{duration}"/> + <testCase name="StringRef/Copy construction is shallow" duration="{duration}"/> + <testCase name="StringRef/Copy assignment is shallow" duration="{duration}"/> <testCase name="StringRef/Substrings/zero-based substring" duration="{duration}"/> <testCase name="StringRef/Substrings/non-zero-based substring" duration="{duration}"/> <testCase name="StringRef/Substrings/Pointer values of full refs should match" duration="{duration}"/> diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index e3d75dd8..0a587189 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -2792,6 +2792,10 @@ ok {test-number} - original == "original" # StringRef ok {test-number} - original.data() # StringRef +ok {test-number} - original.begin() == copy.begin() for: "original string" == "original string" +# StringRef +ok {test-number} - original.begin() == copy.begin() for: "original string" == "original string" +# StringRef ok {test-number} - ss.empty() == false for: false == false # StringRef ok {test-number} - ss.size() == 5 for: 5 == 5 @@ -4402,5 +4406,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2200 +1..2202 diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 2551e03b..fd542b29 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -13222,6 +13222,28 @@ Message from section two </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> </Section> + <Section name="Copy construction is shallow" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" > + <Original> + original.begin() == copy.begin() + </Original> + <Expanded> + "original string" == "original string" + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> + <Section name="Copy assignment is shallow" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" > + <Original> + original.begin() == copy.begin() + </Original> + <Expanded> + "original string" == "original string" + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> <Section name="Substrings" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Section name="zero-based substring" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" > @@ -20573,6 +20595,6 @@ loose text artifact </Section> <OverallResult success="true"/> </TestCase> - <OverallResults successes="2027" failures="146" expectedFailures="27"/> + <OverallResults successes="2029" failures="146" expectedFailures="27"/> <OverallResultsCases successes="291" failures="86" expectedFailures="7"/> </Catch2TestRun> diff --git a/tests/SelfTest/IntrospectiveTests/String.tests.cpp b/tests/SelfTest/IntrospectiveTests/String.tests.cpp index 9fd8a780..6245ca77 100644 --- a/tests/SelfTest/IntrospectiveTests/String.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/String.tests.cpp @@ -29,7 +29,17 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) { REQUIRE_NOTHROW(original.data()); } - + SECTION( "Copy construction is shallow" ) { + StringRef original = StringRef( "original string" ); + StringRef copy = original; + REQUIRE(original.begin() == copy.begin()); + } + SECTION( "Copy assignment is shallow" ) { + StringRef original = StringRef( "original string" ); + StringRef copy; + copy = original; + REQUIRE(original.begin() == copy.begin()); + } SECTION( "Substrings" ) { StringRef s = "hello world!"; |