diff options
| author | Martin Hořeňovský | 2026-09-06 23:23:23 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2026-09-11 11:15:58 +0200 |
| commit | 6a5075bf73273ecb83fca61efdfde2fa1a2690bf (patch) | |
| tree | 6b5f8e4a6c02d653caf57b0059bc25d2d5306d2a | |
| parent | 15db9be53067d66ecd11a7ddd3097d412047130a (diff) | |
| download | catch3-6a5075bf73273ecb83fca61efdfde2fa1a2690bf.tar.gz | |
Use locale-independent toLower
We generally do not even try to pretend to support more than plain ASCII,
because doing unicode in old C++ standards is a pain and a half. For
`toLower`, we used to wrap `std::tolower` with multiple casts to avoid UB,
but calling into it is relatively slow, and it tries to handle different
locales, which could cause unexpected results.
In addition, the new implementation is significantly faster, which helps
speed up the initial process bring up (as comparing tags, and thus test
cases is now faster).
20 files changed, 612 insertions, 23 deletions
diff --git a/src/catch2/internal/catch_string_manip.cpp b/src/catch2/internal/catch_string_manip.cpp index 68983787..ac88be2e 100644 --- a/src/catch2/internal/catch_string_manip.cpp +++ b/src/catch2/internal/catch_string_manip.cpp @@ -11,7 +11,6 @@ #include <ostream> #include <cstring> -#include <cctype> #include <vector> namespace Catch { @@ -41,9 +40,6 @@ namespace Catch { toLowerInPlace( lc ); return lc; } - char toLower(char c) { - return static_cast<char>(std::tolower(static_cast<unsigned char>(c))); - } std::string trim( std::string const& str ) { static char const* whitespaceChars = "\n\r\t "; diff --git a/src/catch2/internal/catch_string_manip.hpp b/src/catch2/internal/catch_string_manip.hpp index 4251f83d..ce317c60 100644 --- a/src/catch2/internal/catch_string_manip.hpp +++ b/src/catch2/internal/catch_string_manip.hpp @@ -25,7 +25,12 @@ namespace Catch { bool contains( std::string const& s, std::string const& infix ); void toLowerInPlace( std::string& s ); std::string toLower( std::string const& s ); - char toLower( char c ); + //! ASCII only. + constexpr char toLower( char c ) { + const uint32_t as_number = static_cast<unsigned char>( c ); + const bool isUpper = ( as_number - static_cast<uint32_t>( 'A' ) ) < 26u; + return static_cast<char>( as_number | ( isUpper << 5 ) ); + } //! Returns a new string without whitespace at the start/end std::string trim( std::string const& str ); //! Returns a substring of the original ref without whitespace. Beware lifetimes! diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index a25bc52a..e8f822df 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -438,6 +438,7 @@ b1! :test-result: PASS tags with dots in later positions are not parsed as hidden :test-result: SKIP tests can be skipped dynamically at runtime :test-result: FAIL thrown std::strings are translated +:test-result: PASS toLower( char ) :test-result: PASS toString on const wchar_t const pointer returns the string contents :test-result: PASS toString on const wchar_t pointer returns the string contents :test-result: PASS toString on wchar_t const pointer returns the string contents diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt index 3f846b7b..738c6faf 100644 --- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt @@ -427,6 +427,7 @@ :test-result: PASS tags with dots in later positions are not parsed as hidden :test-result: SKIP tests can be skipped dynamically at runtime :test-result: FAIL thrown std::strings are translated +:test-result: PASS toLower( char ) :test-result: PASS toString on const wchar_t const pointer returns the string contents :test-result: PASS toString on const wchar_t pointer returns the string contents :test-result: PASS toString on wchar_t const pointer returns the string contents diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index 09c0bc61..643854bc 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -2918,6 +2918,21 @@ Tag.tests.cpp:<line number>: passed: testcase.tags.size() == 1 for: 1 == 1 Tag.tests.cpp:<line number>: passed: testcase.tags[0].original == "magic.tag"_catch_sr for: magic.tag == magic.tag Skip.tests.cpp:<line number>: skipped: Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'Why would you throw a std::string?' +StringManip.tests.cpp:<line number>: passed: toLower( 'A' ) == 'a' for: 'a' == 'a' +StringManip.tests.cpp:<line number>: passed: toLower( 'Z' ) == 'z' for: 'z' == 'z' +StringManip.tests.cpp:<line number>: passed: toLower( 'a' ) == 'a' for: 'a' == 'a' +StringManip.tests.cpp:<line number>: passed: toLower( 'z' ) == 'z' for: 'z' == 'z' +StringManip.tests.cpp:<line number>: passed: toLower( '@' ) == '@' for: '@' == '@' +StringManip.tests.cpp:<line number>: passed: toLower( '[' ) == '[' for: '[' == '[' +StringManip.tests.cpp:<line number>: passed: toLower( '`' ) == '`' for: '`' == '`' +StringManip.tests.cpp:<line number>: passed: toLower( '{' ) == '{' for: '{' == '{' +StringManip.tests.cpp:<line number>: passed: toLower( '0' ) == '0' for: '0' == '0' +StringManip.tests.cpp:<line number>: passed: toLower( ' ' ) == ' ' for: ' ' == ' ' +StringManip.tests.cpp:<line number>: passed: toLower( '\0' ) == '\0' for: 0 == 0 +StringManip.tests.cpp:<line number>: passed: toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) for: 'Ä' == 'Ä' +StringManip.tests.cpp:<line number>: passed: toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) for: 'ÿ' == 'ÿ' +StringManip.tests.cpp:<line number>: passed: with 1 message: 'toLower( 'A' ) == 'a'' +StringManip.tests.cpp:<line number>: passed: with 1 message: 'toLower( '0' ) == '0'' Misc.tests.cpp:<line number>: passed: result == "\"wide load\"" for: ""wide load"" == ""wide load"" Misc.tests.cpp:<line number>: passed: result == "\"wide load\"" for: ""wide load"" == ""wide load"" Misc.tests.cpp:<line number>: passed: result == "\"wide load\"" for: ""wide load"" == ""wide load"" @@ -3015,7 +3030,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:<line number>: passed: Misc.tests.cpp:<line number>: passed: -test cases: 454 | 334 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2423 | 2222 passed | 158 failed | 43 failed as expected +test cases: 455 | 335 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2438 | 2237 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index 5a2a6e03..324ffee2 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -2907,6 +2907,21 @@ Tag.tests.cpp:<line number>: passed: testcase.tags.size() == 1 for: 1 == 1 Tag.tests.cpp:<line number>: passed: testcase.tags[0].original == "magic.tag"_catch_sr for: magic.tag == magic.tag Skip.tests.cpp:<line number>: skipped: Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'Why would you throw a std::string?' +StringManip.tests.cpp:<line number>: passed: toLower( 'A' ) == 'a' for: 'a' == 'a' +StringManip.tests.cpp:<line number>: passed: toLower( 'Z' ) == 'z' for: 'z' == 'z' +StringManip.tests.cpp:<line number>: passed: toLower( 'a' ) == 'a' for: 'a' == 'a' +StringManip.tests.cpp:<line number>: passed: toLower( 'z' ) == 'z' for: 'z' == 'z' +StringManip.tests.cpp:<line number>: passed: toLower( '@' ) == '@' for: '@' == '@' +StringManip.tests.cpp:<line number>: passed: toLower( '[' ) == '[' for: '[' == '[' +StringManip.tests.cpp:<line number>: passed: toLower( '`' ) == '`' for: '`' == '`' +StringManip.tests.cpp:<line number>: passed: toLower( '{' ) == '{' for: '{' == '{' +StringManip.tests.cpp:<line number>: passed: toLower( '0' ) == '0' for: '0' == '0' +StringManip.tests.cpp:<line number>: passed: toLower( ' ' ) == ' ' for: ' ' == ' ' +StringManip.tests.cpp:<line number>: passed: toLower( '\0' ) == '\0' for: 0 == 0 +StringManip.tests.cpp:<line number>: passed: toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) for: 'Ä' == 'Ä' +StringManip.tests.cpp:<line number>: passed: toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) for: 'ÿ' == 'ÿ' +StringManip.tests.cpp:<line number>: passed: with 1 message: 'toLower( 'A' ) == 'a'' +StringManip.tests.cpp:<line number>: passed: with 1 message: 'toLower( '0' ) == '0'' Misc.tests.cpp:<line number>: passed: result == "\"wide load\"" for: ""wide load"" == ""wide load"" Misc.tests.cpp:<line number>: passed: result == "\"wide load\"" for: ""wide load"" == ""wide load"" Misc.tests.cpp:<line number>: passed: result == "\"wide load\"" for: ""wide load"" == ""wide load"" @@ -3004,7 +3019,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:<line number>: passed: Misc.tests.cpp:<line number>: passed: -test cases: 454 | 334 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2423 | 2222 passed | 158 failed | 43 failed as expected +test cases: 455 | 335 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2438 | 2237 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index 344c5b03..f6b88d30 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -1743,6 +1743,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 454 | 352 passed | 76 failed | 7 skipped | 19 failed as expected -assertions: 2401 | 2222 passed | 136 failed | 43 failed as expected +test cases: 455 | 353 passed | 76 failed | 7 skipped | 19 failed as expected +assertions: 2416 | 2237 passed | 136 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index f5324947..311dde19 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -19514,6 +19514,107 @@ due to unexpected exception with message: Why would you throw a std::string? ------------------------------------------------------------------------------- +toLower( char ) + ASCII letters are lowercased +------------------------------------------------------------------------------- +StringManip.tests.cpp:<line number> +............................................................................... + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( 'A' ) == 'a' ) +with expansion: + 'a' == 'a' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( 'Z' ) == 'z' ) +with expansion: + 'z' == 'z' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( 'a' ) == 'a' ) +with expansion: + 'a' == 'a' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( 'z' ) == 'z' ) +with expansion: + 'z' == 'z' + +------------------------------------------------------------------------------- +toLower( char ) + Chars outside 'A'-'Z' are left alone +------------------------------------------------------------------------------- +StringManip.tests.cpp:<line number> +............................................................................... + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '@' ) == '@' ) +with expansion: + '@' == '@' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '[' ) == '[' ) +with expansion: + '[' == '[' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '`' ) == '`' ) +with expansion: + '`' == '`' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '{' ) == '{' ) +with expansion: + '{' == '{' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '0' ) == '0' ) +with expansion: + '0' == '0' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( ' ' ) == ' ' ) +with expansion: + ' ' == ' ' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '\0' ) == '\0' ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +toLower( char ) + Non-ASCII chars are left alone +------------------------------------------------------------------------------- +StringManip.tests.cpp:<line number> +............................................................................... + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) ) +with expansion: + 'Ä' == 'Ä' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) ) +with expansion: + 'm' == 'm' + +------------------------------------------------------------------------------- +toLower( char ) + Is usable in constant expressions +------------------------------------------------------------------------------- +StringManip.tests.cpp:<line number> +............................................................................... + +StringManip.tests.cpp:<line number>: PASSED: +with message: + toLower( 'A' ) == 'a' + +StringManip.tests.cpp:<line number>: PASSED: +with message: + toLower( '0' ) == '0' + +------------------------------------------------------------------------------- toString on const wchar_t const pointer returns the string contents ------------------------------------------------------------------------------- Misc.tests.cpp:<line number> @@ -20226,6 +20327,6 @@ Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>: PASSED: =============================================================================== -test cases: 454 | 334 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2423 | 2222 passed | 158 failed | 43 failed as expected +test cases: 455 | 335 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2438 | 2237 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index 9dba6123..6ddafb08 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -19503,6 +19503,107 @@ due to unexpected exception with message: Why would you throw a std::string? ------------------------------------------------------------------------------- +toLower( char ) + ASCII letters are lowercased +------------------------------------------------------------------------------- +StringManip.tests.cpp:<line number> +............................................................................... + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( 'A' ) == 'a' ) +with expansion: + 'a' == 'a' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( 'Z' ) == 'z' ) +with expansion: + 'z' == 'z' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( 'a' ) == 'a' ) +with expansion: + 'a' == 'a' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( 'z' ) == 'z' ) +with expansion: + 'z' == 'z' + +------------------------------------------------------------------------------- +toLower( char ) + Chars outside 'A'-'Z' are left alone +------------------------------------------------------------------------------- +StringManip.tests.cpp:<line number> +............................................................................... + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '@' ) == '@' ) +with expansion: + '@' == '@' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '[' ) == '[' ) +with expansion: + '[' == '[' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '`' ) == '`' ) +with expansion: + '`' == '`' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '{' ) == '{' ) +with expansion: + '{' == '{' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '0' ) == '0' ) +with expansion: + '0' == '0' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( ' ' ) == ' ' ) +with expansion: + ' ' == ' ' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( '\0' ) == '\0' ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +toLower( char ) + Non-ASCII chars are left alone +------------------------------------------------------------------------------- +StringManip.tests.cpp:<line number> +............................................................................... + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) ) +with expansion: + 'Ä' == 'Ä' + +StringManip.tests.cpp:<line number>: PASSED: + CHECK( toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) ) +with expansion: + 'm' == 'm' + +------------------------------------------------------------------------------- +toLower( char ) + Is usable in constant expressions +------------------------------------------------------------------------------- +StringManip.tests.cpp:<line number> +............................................................................... + +StringManip.tests.cpp:<line number>: PASSED: +with message: + toLower( 'A' ) == 'a' + +StringManip.tests.cpp:<line number>: PASSED: +with message: + toLower( '0' ) == '0' + +------------------------------------------------------------------------------- toString on const wchar_t const pointer returns the string contents ------------------------------------------------------------------------------- Misc.tests.cpp:<line number> @@ -20215,6 +20316,6 @@ Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>: PASSED: =============================================================================== -test cases: 454 | 334 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2423 | 2222 passed | 158 failed | 43 failed as expected +test cases: 455 | 335 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2438 | 2237 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index f58412b6..967646c6 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="141" skipped="12" tests="2435" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> + <testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2450" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <properties> <property name="random-seed" value="1"/> <property name="filters" value=""*" ~[!nonportable] ~[!benchmark] ~[approvals]"/> @@ -1885,6 +1885,11 @@ Why would you throw a std::string? at Exception.tests.cpp:<line number> </error> </testcase> + <testcase classname="<exe-name>.global" name="toLower( char )" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="toLower( char )/ASCII letters are lowercased" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="toLower( char )/Chars outside 'A'-'Z' are left alone" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="toLower( char )/Non-ASCII chars are left alone" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="toLower( char )/Is usable in constant expressions" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="toString on const wchar_t const pointer returns the string contents" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="toString on const wchar_t pointer returns the string contents" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="toString on wchar_t const pointer returns the string contents" time="{duration}" status="run"/> diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index c80e5855..291df00e 100644 --- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <testsuites> - <testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2435" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> + <testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2450" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <properties> <property name="random-seed" value="1"/> <property name="filters" value=""*" ~[!nonportable] ~[!benchmark] ~[approvals]"/> @@ -1884,6 +1884,11 @@ Why would you throw a std::string? at Exception.tests.cpp:<line number> </error> </testcase> + <testcase classname="<exe-name>.global" name="toLower( char )" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="toLower( char )/ASCII letters are lowercased" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="toLower( char )/Chars outside 'A'-'Z' are left alone" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="toLower( char )/Non-ASCII chars are left alone" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="toLower( char )/Is usable in constant expressions" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="toString on const wchar_t const pointer returns the string contents" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="toString on const wchar_t pointer returns the string contents" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="toString on wchar_t const pointer returns the string contents" time="{duration}" status="run"/> diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index 17c26f36..9beaed2c 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -400,6 +400,11 @@ at AssertionHandler.tests.cpp:<line number> <testCase name="replaceInPlace/escape '" duration="{duration}"/> <testCase name="splitString" duration="{duration}"/> <testCase name="startsWith" duration="{duration}"/> + <testCase name="toLower( char )" duration="{duration}"/> + <testCase name="toLower( char )/ASCII letters are lowercased" duration="{duration}"/> + <testCase name="toLower( char )/Chars outside 'A'-'Z' are left alone" duration="{duration}"/> + <testCase name="toLower( char )/Non-ASCII chars are left alone" duration="{duration}"/> + <testCase name="toLower( char )/Is usable in constant expressions" duration="{duration}"/> </file> <file path="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp"> <testCase name="Tag alias can be registered against tag patterns" duration="{duration}"/> diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index 4c113189..25194b72 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -399,6 +399,11 @@ at AssertionHandler.tests.cpp:<line number> <testCase name="replaceInPlace/escape '" duration="{duration}"/> <testCase name="splitString" duration="{duration}"/> <testCase name="startsWith" duration="{duration}"/> + <testCase name="toLower( char )" duration="{duration}"/> + <testCase name="toLower( char )/ASCII letters are lowercased" duration="{duration}"/> + <testCase name="toLower( char )/Chars outside 'A'-'Z' are left alone" duration="{duration}"/> + <testCase name="toLower( char )/Non-ASCII chars are left alone" duration="{duration}"/> + <testCase name="toLower( char )/Is usable in constant expressions" duration="{duration}"/> </file> <file path="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp"> <testCase name="Tag alias can be registered against tag patterns" duration="{duration}"/> diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index 6fa5949e..84482410 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -4691,6 +4691,36 @@ ok {test-number} - testcase.tags[0].original == "magic.tag"_catch_sr for: magic. ok {test-number} - # SKIP # thrown std::strings are translated not ok {test-number} - unexpected exception with message: 'Why would you throw a std::string?' +# toLower( char ) +ok {test-number} - toLower( 'A' ) == 'a' for: 'a' == 'a' +# toLower( char ) +ok {test-number} - toLower( 'Z' ) == 'z' for: 'z' == 'z' +# toLower( char ) +ok {test-number} - toLower( 'a' ) == 'a' for: 'a' == 'a' +# toLower( char ) +ok {test-number} - toLower( 'z' ) == 'z' for: 'z' == 'z' +# toLower( char ) +ok {test-number} - toLower( '@' ) == '@' for: '@' == '@' +# toLower( char ) +ok {test-number} - toLower( '[' ) == '[' for: '[' == '[' +# toLower( char ) +ok {test-number} - toLower( '`' ) == '`' for: '`' == '`' +# toLower( char ) +ok {test-number} - toLower( '{' ) == '{' for: '{' == '{' +# toLower( char ) +ok {test-number} - toLower( '0' ) == '0' for: '0' == '0' +# toLower( char ) +ok {test-number} - toLower( ' ' ) == ' ' for: ' ' == ' ' +# toLower( char ) +ok {test-number} - toLower( '\0' ) == '\0' for: 0 == 0 +# toLower( char ) +ok {test-number} - toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) for: 'Ä' == 'Ä' +# toLower( char ) +ok {test-number} - toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) for: 'ÿ' == 'ÿ' +# toLower( char ) +ok {test-number} - with 1 message: 'toLower( 'A' ) == 'a'' +# toLower( char ) +ok {test-number} - with 1 message: 'toLower( '0' ) == '0'' # toString on const wchar_t const pointer returns the string contents ok {test-number} - result == "\"wide load\"" for: ""wide load"" == ""wide load"" # toString on const wchar_t pointer returns the string contents @@ -4865,5 +4895,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2435 +1..2450 diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index 0a7d381a..bdfa3bf5 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -4680,6 +4680,36 @@ ok {test-number} - testcase.tags[0].original == "magic.tag"_catch_sr for: magic. ok {test-number} - # SKIP # thrown std::strings are translated not ok {test-number} - unexpected exception with message: 'Why would you throw a std::string?' +# toLower( char ) +ok {test-number} - toLower( 'A' ) == 'a' for: 'a' == 'a' +# toLower( char ) +ok {test-number} - toLower( 'Z' ) == 'z' for: 'z' == 'z' +# toLower( char ) +ok {test-number} - toLower( 'a' ) == 'a' for: 'a' == 'a' +# toLower( char ) +ok {test-number} - toLower( 'z' ) == 'z' for: 'z' == 'z' +# toLower( char ) +ok {test-number} - toLower( '@' ) == '@' for: '@' == '@' +# toLower( char ) +ok {test-number} - toLower( '[' ) == '[' for: '[' == '[' +# toLower( char ) +ok {test-number} - toLower( '`' ) == '`' for: '`' == '`' +# toLower( char ) +ok {test-number} - toLower( '{' ) == '{' for: '{' == '{' +# toLower( char ) +ok {test-number} - toLower( '0' ) == '0' for: '0' == '0' +# toLower( char ) +ok {test-number} - toLower( ' ' ) == ' ' for: ' ' == ' ' +# toLower( char ) +ok {test-number} - toLower( '\0' ) == '\0' for: 0 == 0 +# toLower( char ) +ok {test-number} - toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) for: 'Ä' == 'Ä' +# toLower( char ) +ok {test-number} - toLower( static_cast<char>( 0x<hex digits> ) ) == static_cast<char>( 0x<hex digits> ) for: 'ÿ' == 'ÿ' +# toLower( char ) +ok {test-number} - with 1 message: 'toLower( 'A' ) == 'a'' +# toLower( char ) +ok {test-number} - with 1 message: 'toLower( '0' ) == '0'' # toString on const wchar_t const pointer returns the string contents ok {test-number} - result == "\"wide load\"" for: ""wide load"" == ""wide load"" # toString on const wchar_t pointer returns the string contents @@ -4854,5 +4884,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2435 +1..2450 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index 16fe73f9..9768478b 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/ |