diff --git a/include/internal/catch_stringref.cpp b/include/internal/catch_stringref.cpp index 90a320c9..8e6741b1 100644 --- a/include/internal/catch_stringref.cpp +++ b/include/internal/catch_stringref.cpp @@ -17,12 +17,6 @@ #include #include -namespace { - const uint32_t byte_2_lead = 0xC0; - const uint32_t byte_3_lead = 0xE0; - const uint32_t byte_4_lead = 0xF0; -} - namespace Catch { StringRef::StringRef( char const* rawChars ) noexcept : StringRef( rawChars, static_cast(std::strlen(rawChars) ) ) @@ -82,22 +76,6 @@ namespace Catch { return m_start[index]; } - auto StringRef::numberOfCharacters() const noexcept -> size_type { - size_type noChars = m_size; - // Make adjustments for uft encodings - for( size_type i=0; i < m_size; ++i ) { - char c = m_start[i]; - if( ( c & byte_2_lead ) == byte_2_lead ) { - noChars--; - if (( c & byte_3_lead ) == byte_3_lead ) - noChars--; - if( ( c & byte_4_lead ) == byte_4_lead ) - noChars--; - } - } - return noChars; - } - auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string { std::string str; str.reserve( lhs.size() + rhs.size() ); diff --git a/include/internal/catch_stringref.h b/include/internal/catch_stringref.h index 64f595b3..f7e4a360 100644 --- a/include/internal/catch_stringref.h +++ b/include/internal/catch_stringref.h @@ -96,7 +96,6 @@ namespace Catch { return m_size; } - auto numberOfCharacters() const noexcept -> size_type; auto c_str() const -> char const*; public: // substrings and searches diff --git a/include/reporters/catch_reporter_console.cpp b/include/reporters/catch_reporter_console.cpp index ff3953e4..12092907 100644 --- a/include/reporters/catch_reporter_console.cpp +++ b/include/reporters/catch_reporter_console.cpp @@ -321,8 +321,7 @@ public: friend TablePrinter& operator << (TablePrinter& tp, ColumnBreak) { auto colStr = tp.m_oss.str(); - // This takes account of utf8 encodings - auto strSize = Catch::StringRef(colStr).numberOfCharacters(); + const auto strSize = colStr.size(); tp.m_oss.str(""); tp.open(); if (tp.m_currentColumn == static_cast(tp.m_columnInfos.size() - 1)) { diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index e6d28f39..20fade32 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -1045,9 +1045,6 @@ String.tests.cpp:: passed: stdStr == "a stringref" for: "a stringre String.tests.cpp:: passed: stdStr.size() == sr.size() for: 11 == 11 String.tests.cpp:: passed: stdStr == "a stringref" for: "a stringref" == "a stringref" String.tests.cpp:: passed: stdStr.size() == sr.size() for: 11 == 11 -String.tests.cpp:: passed: ascii.numberOfCharacters() == ascii.size() for: 39 == 39 -String.tests.cpp:: passed: simpleu8.numberOfCharacters() == 30 for: 30 == 30 -String.tests.cpp:: passed: emojis.numberOfCharacters() == 9 for: 9 == 9 ToStringChrono.tests.cpp:: passed: minute == seconds for: 1 m == 60 s ToStringChrono.tests.cpp:: passed: hour != seconds for: 1 h != 60 s ToStringChrono.tests.cpp:: passed: micro != milli for: 1 us != 1 ms diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 756ea25e..59ea0426 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1381,5 +1381,5 @@ due to unexpected exception with message: =============================================================================== test cases: 300 | 226 passed | 70 failed | 4 failed as expected -assertions: 1562 | 1410 passed | 131 failed | 21 failed as expected +assertions: 1559 | 1407 passed | 131 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 8e5501f7..11eedbb4 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -7837,28 +7837,6 @@ String.tests.cpp:: PASSED: with expansion: 11 == 11 -------------------------------------------------------------------------------- -StringRef - Counting utf-8 codepoints -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( ascii.numberOfCharacters() == ascii.size() ) -with expansion: - 39 == 39 - -String.tests.cpp:: PASSED: - REQUIRE( simpleu8.numberOfCharacters() == 30 ) -with expansion: - 30 == 30 - -String.tests.cpp:: PASSED: - REQUIRE( emojis.numberOfCharacters() == 9 ) -with expansion: - 9 == 9 - ------------------------------------------------------------------------------- Stringifying std::chrono::duration helpers ------------------------------------------------------------------------------- @@ -12484,5 +12462,5 @@ Misc.tests.cpp:: PASSED: =============================================================================== test cases: 300 | 210 passed | 86 failed | 4 failed as expected -assertions: 1579 | 1410 passed | 148 failed | 21 failed as expected +assertions: 1576 | 1407 passed | 148 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index d0e54846..11930e67 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -729,7 +729,6 @@ Matchers.tests.cpp: - diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index d848e615..03c11cde 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -9667,33 +9667,6 @@ Message from section two -
- - - ascii.numberOfCharacters() == ascii.size() - - - 39 == 39 - - - - - simpleu8.numberOfCharacters() == 30 - - - 30 == 30 - - - - - emojis.numberOfCharacters() == 9 - - - 9 == 9 - - - -
@@ -14861,7 +14834,7 @@ loose text artifact - + - + diff --git a/projects/SelfTest/IntrospectiveTests/String.tests.cpp b/projects/SelfTest/IntrospectiveTests/String.tests.cpp index 876d4a09..aedd2f38 100644 --- a/projects/SelfTest/IntrospectiveTests/String.tests.cpp +++ b/projects/SelfTest/IntrospectiveTests/String.tests.cpp @@ -159,18 +159,6 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) { REQUIRE( stdStr.size() == sr.size() ); } } - - SECTION( "Counting utf-8 codepoints" ) { - StringRef ascii = "just a plain old boring ascii string..."; - REQUIRE(ascii.numberOfCharacters() == ascii.size()); - - StringRef simpleu8 = u8"Trocha češtiny nikoho nezabila"; - REQUIRE(simpleu8.numberOfCharacters() == 30); - - StringRef emojis = u8"Here be 👾"; - REQUIRE(emojis.numberOfCharacters() == 9); - } - } TEST_CASE( "replaceInPlace", "[Strings][StringManip]" ) {