diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-12-10 08:56:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 08:56:31 +0100 |
commit | bdf8340e5993ec3f86e4bf1d5ede48df7d023a12 (patch) | |
tree | 1e366583662397e366d4f84bb334660db37cb5bd /tests/core/string/test_string.h | |
parent | 5ad9d8bad69309d71ea55f3d799af7e3711dc262 (diff) | |
parent | 49403cbfa0399bb4284ea5c36cc90216a0bda6ff (diff) |
Merge pull request #43181 from nathanfranke/string-empty
Replace String comparisons with "", String() to is_empty()
Diffstat (limited to 'tests/core/string/test_string.h')
-rw-r--r-- | tests/core/string/test_string.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index 00a9a8779a..eef1cac894 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -157,10 +157,10 @@ TEST_CASE("[String] Invalid UTF8") { String s; bool err = s.parse_utf8((const char *)u8str); CHECK(err); - CHECK(s == String()); + CHECK(s.is_empty()); CharString cs = (const char *)u8str; - CHECK(String::utf8(cs) == String()); + CHECK(String::utf8(cs).is_empty()); ERR_PRINT_ON } @@ -170,10 +170,10 @@ TEST_CASE("[String] Invalid UTF16") { String s; bool err = s.parse_utf16(u16str); CHECK(err); - CHECK(s == String()); + CHECK(s.is_empty()); Char16String cs = u16str; - CHECK(String::utf16(cs) == String()); + CHECK(String::utf16(cs).is_empty()); ERR_PRINT_ON } @@ -1439,6 +1439,24 @@ TEST_CASE("[String] Variant ptr indexed set") { CHECK_EQ(s, String("azcd")); } + +TEST_CASE("[Stress][String] Empty via ' == String()'") { + for (int i = 0; i < 100000; ++i) { + String str = "Hello World!"; + if (str.is_empty()) { + continue; + } + } +} + +TEST_CASE("[Stress][String] Empty via `is_empty()`") { + for (int i = 0; i < 100000; ++i) { + String str = "Hello World!"; + if (str.is_empty()) { + continue; + } + } +} } // namespace TestString #endif // TEST_STRING_H |