mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Add tests for StringRef's copy operations being shallow
This commit is contained in:
parent
72a09de236
commit
8711b63a0a
@ -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: s.data() == rawChars for: "hello" == "hello"
|
||||||
String.tests.cpp:<line number>: passed: original == "original"
|
String.tests.cpp:<line number>: passed: original == "original"
|
||||||
String.tests.cpp:<line number>: passed: original.data()
|
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.empty() == false for: false == false
|
||||||
String.tests.cpp:<line number>: passed: ss.size() == 5 for: 5 == 5
|
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
|
String.tests.cpp:<line number>: passed: std::strncmp( ss.data(), "hello", 5 ) == 0 for: 0 == 0
|
||||||
|
@ -1427,5 +1427,5 @@ due to unexpected exception with message:
|
|||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 384 | 307 passed | 70 failed | 7 failed as expected
|
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
|
||||||
|
|
||||||
|
@ -11079,6 +11079,30 @@ String.tests.cpp:<line number>: PASSED:
|
|||||||
String.tests.cpp:<line number>: PASSED:
|
String.tests.cpp:<line number>: PASSED:
|
||||||
REQUIRE_NOTHROW( original.data() )
|
REQUIRE_NOTHROW( original.data() )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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
|
StringRef
|
||||||
Substrings
|
Substrings
|
||||||
@ -17541,5 +17565,5 @@ Misc.tests.cpp:<line number>: PASSED:
|
|||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 384 | 291 passed | 86 failed | 7 failed as expected
|
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
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<testsuitesloose text artifact
|
<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>
|
<properties>
|
||||||
<property name="random-seed" value="1"/>
|
<property name="random-seed" value="1"/>
|
||||||
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
|
<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/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 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/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/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/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"/>
|
<testcase classname="<exe-name>.global" name="StringRef/Substrings/Pointer values of full refs should match" time="{duration}" status="run"/>
|
||||||
|
@ -210,6 +210,8 @@
|
|||||||
<testCase name="StringRef/Empty string" duration="{duration}"/>
|
<testCase name="StringRef/Empty string" duration="{duration}"/>
|
||||||
<testCase name="StringRef/From string literal" duration="{duration}"/>
|
<testCase name="StringRef/From string literal" duration="{duration}"/>
|
||||||
<testCase name="StringRef/From sub-string" 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/zero-based substring" duration="{duration}"/>
|
||||||
<testCase name="StringRef/Substrings/non-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}"/>
|
<testCase name="StringRef/Substrings/Pointer values of full refs should match" duration="{duration}"/>
|
||||||
|
@ -2792,6 +2792,10 @@ ok {test-number} - original == "original"
|
|||||||
# StringRef
|
# StringRef
|
||||||
ok {test-number} - original.data()
|
ok {test-number} - original.data()
|
||||||
# StringRef
|
# 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
|
ok {test-number} - ss.empty() == false for: false == false
|
||||||
# StringRef
|
# StringRef
|
||||||
ok {test-number} - ss.size() == 5 for: 5 == 5
|
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} -
|
ok {test-number} -
|
||||||
# xmlentitycheck
|
# xmlentitycheck
|
||||||
ok {test-number} -
|
ok {test-number} -
|
||||||
1..2200
|
1..2202
|
||||||
|
|
||||||
|
@ -13222,6 +13222,28 @@ Message from section two
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
||||||
</Section>
|
</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="Substrings" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
|
||||||
<Section name="zero-based substring" 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" >
|
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/String.tests.cpp" >
|
||||||
@ -20573,6 +20595,6 @@ loose text artifact
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<OverallResults successes="2027" failures="146" expectedFailures="27"/>
|
<OverallResults successes="2029" failures="146" expectedFailures="27"/>
|
||||||
<OverallResultsCases successes="291" failures="86" expectedFailures="7"/>
|
<OverallResultsCases successes="291" failures="86" expectedFailures="7"/>
|
||||||
</Catch2TestRun>
|
</Catch2TestRun>
|
||||||
|
@ -29,7 +29,17 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) {
|
|||||||
|
|
||||||
REQUIRE_NOTHROW(original.data());
|
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" ) {
|
SECTION( "Substrings" ) {
|
||||||
StringRef s = "hello world!";
|
StringRef s = "hello world!";
|
||||||
|
Loading…
Reference in New Issue
Block a user