summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/core/io/test_file_access.h2
-rw-r--r--tests/core/math/test_math.cpp2
-rw-r--r--tests/core/string/test_string.h26
-rw-r--r--tests/scene/test_code_edit.h2
4 files changed, 25 insertions, 7 deletions
diff --git a/tests/core/io/test_file_access.h b/tests/core/io/test_file_access.h
index 4ffc57afe4..f566899c9b 100644
--- a/tests/core/io/test_file_access.h
+++ b/tests/core/io/test_file_access.h
@@ -53,7 +53,7 @@ TEST_CASE("[FileAccess] CSV read") {
REQUIRE(row2.size() == 3);
CHECK(row2[0] == "GOOD_EVENING");
CHECK(row2[1] == "Good Evening");
- CHECK(row2[2] == ""); // Use case: not yet translated!
+ CHECK(row2[2].is_empty()); // Use case: not yet translated!
// https://github.com/godotengine/godot/issues/44269
CHECK_MESSAGE(row2[2] != "\"", "Should not parse empty string as a single double quote.");
diff --git a/tests/core/math/test_math.cpp b/tests/core/math/test_math.cpp
index 6ec9bc2473..97e6055130 100644
--- a/tests/core/math/test_math.cpp
+++ b/tests/core/math/test_math.cpp
@@ -312,7 +312,7 @@ public:
}
}
- if (name != String()) {
+ if (!name.is_empty()) {
namespace_stack[at_level] = name;
}
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
diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h
index 0467d4417b..4b5a049a07 100644
--- a/tests/scene/test_code_edit.h
+++ b/tests/scene/test_code_edit.h
@@ -3235,7 +3235,7 @@ TEST_CASE("[SceneTree][CodeEdit] Backspace delete") {
code_edit->insert_text_at_caret("line 1\nline 2\nline 3");
code_edit->select_all();
code_edit->backspace();
- CHECK(code_edit->get_text() == "");
+ CHECK(code_edit->get_text().is_empty());
/* Backspace at the beginning without selection has no effect. */
code_edit->set_text("");