mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Replace String comparisons with "", String() to is_empty()
Also: - Adds two stress tests to test_string.h - Changes to .empty() on std::strings
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user