summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorrune-scape <allie.smith.epic@gmail.com>2022-12-05 21:46:47 -0500
committerrune-scape <allie.smith.epic@gmail.com>2022-12-05 21:46:47 -0500
commite79be6ce07ed8c89011f759ecade070a3bd5a806 (patch)
treefbe13a625acf7630c4a5aeb4a8664e6c67472818 /tests
parentf3e6750a7e4702918e05f42b1376e30e652f2f90 (diff)
Unify String and StringName
Diffstat (limited to 'tests')
-rw-r--r--tests/core/variant/test_dictionary.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/core/variant/test_dictionary.h b/tests/core/variant/test_dictionary.h
index c98434d42c..0c87f11ed7 100644
--- a/tests/core/variant/test_dictionary.h
+++ b/tests/core/variant/test_dictionary.h
@@ -64,6 +64,19 @@ TEST_CASE("[Dictionary] Assignment using bracket notation ([])") {
map["World!"] = 4;
CHECK(int(map["World!"]) == 4);
+ map[StringName("HelloName")] = 6;
+ CHECK(int(map[StringName("HelloName")]) == 6);
+ // Check that StringName key is converted to String.
+ CHECK(int(map.find_key(6).get_type()) == Variant::STRING);
+ map[StringName("HelloName")] = 7;
+ CHECK(int(map[StringName("HelloName")]) == 7);
+
+ // Test String and StringName are equivalent.
+ map[StringName("Hello")] = 8;
+ CHECK(int(map["Hello"]) == 8);
+ map["Hello"] = 9;
+ CHECK(int(map[StringName("Hello")]) == 9);
+
// Test non-string keys, since keys can be of any Variant type.
map[12345] = -5;
CHECK(int(map[12345]) == -5);