diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 49f184e9..4a061ae7 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1002,6 +1002,6 @@ with expansion: "first" == "second" =============================================================================== -test cases: 171 | 121 passed | 46 failed | 4 failed as expected -assertions: 844 | 729 passed | 94 failed | 21 failed as expected +test cases: 174 | 124 passed | 46 failed | 4 failed as expected +assertions: 908 | 793 passed | 94 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index e74a3348..c27c1098 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -5692,6 +5692,50 @@ MatchersTests.cpp:: FAILED: with expansion: "this string contains 'abc' as a substring" starts with: "string" +------------------------------------------------------------------------------- +String + empty string +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( empty.empty() ) +with expansion: + true + +String.tests.cpp:: +PASSED: + REQUIRE( empty.size() == 0 ) +with expansion: + 0 == 0 + +String.tests.cpp:: +PASSED: + REQUIRE( std::strcmp( empty.c_str(), "" ) == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +String + from literal +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( s.empty() == false ) +with expansion: + false == false + +String.tests.cpp:: +PASSED: + REQUIRE( s.size() == 5 ) +with expansion: + 5 == 5 + ------------------------------------------------------------------------------- String matchers ------------------------------------------------------------------------------- @@ -5722,6 +5766,504 @@ PASSED: with expansion: "this string contains 'abc' as a substring" ends with: "substring" +------------------------------------------------------------------------------- +StringBuilder + basic +------------------------------------------------------------------------------- +StringBuilder.tests.cpp: +............................................................................... + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( sb.capacity() == 0 ) +with expansion: + 0 == 0 + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( sb.size() == 0 ) +with expansion: + 0 == 0 + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( sb.capacity() == 32 ) +with expansion: + 32 == 32 + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( sb.size() == 0 ) +with expansion: + 0 == 0 + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( sb.capacity() == 32 ) +with expansion: + 32 == 32 + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( sb.size() == 5 ) +with expansion: + 5 == 5 + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( s == "hello" ) +with expansion: + {?} == "hello" + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( s.size() == 5 ) +with expansion: + 5 == 5 + +------------------------------------------------------------------------------- +StringBuilder + concatenation +------------------------------------------------------------------------------- +StringBuilder.tests.cpp: +............................................................................... + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( s == "hello world" ) +with expansion: + {?} == "hello world" + +------------------------------------------------------------------------------- +StringBuilder + concat & move +------------------------------------------------------------------------------- +StringBuilder.tests.cpp: +............................................................................... + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( s == "hello world" ) +with expansion: + {?} == "hello world" + +------------------------------------------------------------------------------- +StringBuilder + reserved +------------------------------------------------------------------------------- +StringBuilder.tests.cpp: +............................................................................... + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( sb16.capacity() == 16 ) +with expansion: + 16 == 16 + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( sb16.capacity() == 16 ) +with expansion: + 16 == 16 + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( s == "hello world" ) +with expansion: + {?} == "hello world" + +------------------------------------------------------------------------------- +StringBuilder + from String + copy +------------------------------------------------------------------------------- +StringBuilder.tests.cpp: +............................................................................... + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( s2 == s ) +with expansion: + {?} == {?} + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( s2.c_str() != s.c_str() ) +with expansion: + "hello" != "hello" + +------------------------------------------------------------------------------- +StringBuilder + from String + move from uniquely owned string +------------------------------------------------------------------------------- +StringBuilder.tests.cpp: +............................................................................... + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( s2 == "hello" ) +with expansion: + {?} == "hello" + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( s2.c_str() == originalPointer ) +with expansion: + "hello" == "hello" + +------------------------------------------------------------------------------- +StringBuilder + from String + move from shared string (copies) +------------------------------------------------------------------------------- +StringBuilder.tests.cpp: +............................................................................... + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( s2 == "hello" ) +with expansion: + {?} == "hello" + +StringBuilder.tests.cpp:: +PASSED: + REQUIRE( s2.c_str() != originalPointer ) +with expansion: + "hello" != "hello" + +------------------------------------------------------------------------------- +StringRef + Empty string +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( empty.empty() ) +with expansion: + true + +StringRef.tests.cpp:: +PASSED: + REQUIRE( empty.size() == 0 ) +with expansion: + 0 == 0 + +StringRef.tests.cpp:: +PASSED: + REQUIRE( std::strcmp( empty.c_str(), "" ) == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +StringRef + From string literal +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( s.empty() == false ) +with expansion: + false == false + +StringRef.tests.cpp:: +PASSED: + REQUIRE( s.size() == 5 ) +with expansion: + 5 == 5 + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isSubstring( s ) == false ) +with expansion: + false == false + +StringRef.tests.cpp:: +PASSED: + REQUIRE( std::strcmp( rawChars, "hello" ) == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +StringRef + From string literal + c_str() does not cause copy +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isOwned( s ) == false ) +with expansion: + false == false + +StringRef.tests.cpp:: +PASSED: + REQUIRE( s.c_str() == rawChars ) +with expansion: + "hello" == "hello" + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isOwned( s ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +StringRef + From sub-string +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( original == "original" ) +with expansion: + {?} == "original" + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isSubstring( original ) ) +with expansion: + true + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isOwned( original ) == false ) +with expansion: + false == false + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isSubstring( original ) == false ) +with expansion: + false == false + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isOwned( original ) ) +with expansion: + true + +------------------------------------------------------------------------------- +StringRef + Substrings + zero-based substring +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( ss.empty() == false ) +with expansion: + false == false + +StringRef.tests.cpp:: +PASSED: + REQUIRE( ss.size() == 5 ) +with expansion: + 5 == 5 + +StringRef.tests.cpp:: +PASSED: + REQUIRE( std::strcmp( ss.c_str(), "hello" ) == 0 ) +with expansion: + 0 == 0 + +StringRef.tests.cpp:: +PASSED: + REQUIRE( ss == "hello" ) +with expansion: + {?} == "hello" + +------------------------------------------------------------------------------- +StringRef + Substrings + c_str() causes copy +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isSubstring( ss ) ) +with expansion: + true + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isOwned( ss ) == false ) +with expansion: + false == false + +StringRef.tests.cpp:: +PASSED: + REQUIRE( rawChars == data( s ) ) +with expansion: + "hello world!" == "hello world!" + +StringRef.tests.cpp:: +PASSED: + REQUIRE( ss.c_str() != rawChars ) +with expansion: + "hello" != "hello world!" + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isSubstring( ss ) == false ) +with expansion: + false == false + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isOwned( ss ) ) +with expansion: + true + +StringRef.tests.cpp:: +PASSED: + REQUIRE( data( ss ) != data( s ) ) +with expansion: + "hello" != "hello world!" + +------------------------------------------------------------------------------- +StringRef + Substrings + non-zero-based substring +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( ss.size() == 6 ) +with expansion: + 6 == 6 + +StringRef.tests.cpp:: +PASSED: + REQUIRE( std::strcmp( ss.c_str(), "world!" ) == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +StringRef + Substrings + Pointer values of full refs should match +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( s.c_str() == s2.c_str() ) +with expansion: + "hello world!" == "hello world!" + +------------------------------------------------------------------------------- +StringRef + Substrings + Pointer values of substring refs should not match +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( s.c_str() != ss.c_str() ) +with expansion: + "hello world!" != "hello" + +------------------------------------------------------------------------------- +StringRef + Comparisons +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( StringRef("hello") == StringRef("hello") ) +with expansion: + {?} == {?} + +StringRef.tests.cpp:: +PASSED: + REQUIRE( StringRef("hello") != StringRef("cello") ) +with expansion: + {?} != {?} + +------------------------------------------------------------------------------- +StringRef + From string + Copied +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( copied == "hot potato" ) +with expansion: + {?} == "hot potato" + +StringRef.tests.cpp:: +PASSED: + REQUIRE( str == "hot potato" ) +with expansion: + {?} == "hot potato" + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isOwned( copied ) == false ) +with expansion: + false == false + +StringRef.tests.cpp:: +PASSED: + REQUIRE( data( copied ) == originalPointer ) +with expansion: + "hot potato" == "hot potato" + +------------------------------------------------------------------------------- +StringRef + From string + Moved +------------------------------------------------------------------------------- +StringRef.tests.cpp: +............................................................................... + +StringRef.tests.cpp:: +PASSED: + REQUIRE( copied == "hot potato" ) +with expansion: + {?} == "hot potato" + +StringRef.tests.cpp:: +PASSED: + REQUIRE( isOwned( copied ) ) +with expansion: + true + +StringRef.tests.cpp:: +PASSED: + REQUIRE( str.empty() ) +with expansion: + true + +StringRef.tests.cpp:: +PASSED: + REQUIRE( data( copied ) == originalPointer ) +with expansion: + "hot potato" == "hot potato" + hello hello ------------------------------------------------------------------------------- @@ -8352,6 +8894,6 @@ MiscTests.cpp:: PASSED: =============================================================================== -test cases: 171 | 120 passed | 47 failed | 4 failed as expected -assertions: 846 | 729 passed | 96 failed | 21 failed as expected +test cases: 174 | 123 passed | 47 failed | 4 failed as expected +assertions: 910 | 793 passed | 96 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index cae1e4bf..91e2307a 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,6 +1,6 @@ - + @@ -512,7 +512,28 @@ Message from section two MatchersTests.cpp: + + + + + + + + + + + + + + + + + + + + + hello diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 948cff19..4e65d8ce 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -6358,6 +6358,55 @@ Message from section two + +
+ + + empty.empty() + + + true + + + + + empty.size() == 0 + + + 0 == 0 + + + + + std::strcmp( empty.c_str(), "" ) == 0 + + + 0 == 0 + + + +
+
+ + + s.empty() == false + + + false == false + + + + + s.size() == 5 + + + 5 == 5 + + + +
+ +
@@ -6393,6 +6442,571 @@ Message from section two + +
+ + + sb.capacity() == 0 + + + 0 == 0 + + + + + sb.size() == 0 + + + 0 == 0 + + + + + sb.capacity() == 32 + + + 32 == 32 + + + + + sb.size() == 0 + + + 0 == 0 + + + + + sb.capacity() == 32 + + + 32 == 32 + + + + + sb.size() == 5 + + + 5 == 5 + + + + + s == "hello" + + + {?} == "hello" + + + + + s.size() == 5 + + + 5 == 5 + + + +
+
+ + + s == "hello world" + + + {?} == "hello world" + + + +
+
+ + + s == "hello world" + + + {?} == "hello world" + + + +
+
+ + + sb16.capacity() == 16 + + + 16 == 16 + + + + + sb16.capacity() == 16 + + + 16 == 16 + + + + + s == "hello world" + + + {?} == "hello world" + + + +
+
+
+ + + s2 == s + + + {?} == {?} + + + + + s2.c_str() != s.c_str() + + + "hello" != "hello" + + + +
+ +
+
+
+ + + s2 == "hello" + + + {?} == "hello" + + + + + s2.c_str() == originalPointer + + + "hello" == "hello" + + + +
+ +
+
+
+ + + s2 == "hello" + + + {?} == "hello" + + + + + s2.c_str() != originalPointer + + + "hello" != "hello" + + + +
+ +
+ +
+ +
+ + + empty.empty() + + + true + + + + + empty.size() == 0 + + + 0 == 0 + + + + + std::strcmp( empty.c_str(), "" ) == 0 + + + 0 == 0 + + + +
+
+ + + s.empty() == false + + + false == false + + + + + s.size() == 5 + + + 5 == 5 + + + + + isSubstring( s ) == false + + + false == false + + + + + std::strcmp( rawChars, "hello" ) == 0 + + + 0 == 0 + + +
+ + + isOwned( s ) == false + + + false == false + + + + + s.c_str() == rawChars + + + "hello" == "hello" + + + + + isOwned( s ) == false + + + false == false + + + +
+ +
+
+ + + original == "original" + + + {?} == "original" + + + + + isSubstring( original ) + + + true + + + + + isOwned( original ) == false + + + false == false + + + + + isSubstring( original ) == false + + + false == false + + + + + isOwned( original ) + + + true + + + +
+
+
+ + + ss.empty() == false + + + false == false + + + + + ss.size() == 5 + + + 5 == 5 + + + + + std::strcmp( ss.c_str(), "hello" ) == 0 + + + 0 == 0 + + + + + ss == "hello" + + + {?} == "hello" + + + +
+ +
+
+
+ + + isSubstring( ss ) + + + true + + + + + isOwned( ss ) == false + + + false == false + + + + + rawChars == data( s ) + + + "hello world!" == "hello world!" + + + + + ss.c_str() != rawChars + + + "hello" != "hello world!" + + + + + isSubstring( ss ) == false + + + false == false + + + + + isOwned( ss ) + + + true + + + + + data( ss ) != data( s ) + + + "hello" != "hello world!" + + + +
+ +
+
+
+ + + ss.size() == 6 + + + 6 == 6 + + + + + std::strcmp( ss.c_str(), "world!" ) == 0 + + + 0 == 0 + + + +
+ +
+
+
+ + + s.c_str() == s2.c_str() + + + "hello world!" == "hello world!" + + + +
+ +
+
+
+ + + s.c_str() != ss.c_str() + + + "hello world!" != "hello" + + + +
+ +
+
+ + + StringRef("hello") == StringRef("hello") + + + {?} == {?} + + + + + StringRef("hello") != StringRef("cello") + + + {?} != {?} + + + +
+
+
+ + + copied == "hot potato" + + + {?} == "hot potato" + + + + + str == "hot potato" + + + {?} == "hot potato" + + + + + isOwned( copied ) == false + + + false == false + + + + + data( copied ) == originalPointer + + + "hot potato" == "hot potato" + + + +
+ +
+
+
+ + + copied == "hot potato" + + + {?} == "hot potato" + + + + + isOwned( copied ) + + + true + + + + + str.empty() + + + true + + + + + data( copied ) == originalPointer + + + "hot potato" == "hot potato" + + + +
+ +
+ +
@@ -9166,7 +9780,7 @@ spanner - + - +