summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2023-06-24 13:03:28 -0500
committerThaddeus Crews <repiteo@outlook.com>2024-09-04 10:27:26 -0500
commit9853a691447cd4e279f48820067174d3833b0065 (patch)
tree7c774abf550b9ededc4df8fac066dbcaae393203 /tests
parent906a4e9db91c2c6b17a0cb1cddf2a96f64114646 (diff)
downloadredot-engine-9853a691447cd4e279f48820067174d3833b0065.tar.gz
Implement typed dictionaries
Diffstat (limited to 'tests')
-rw-r--r--tests/core/variant/test_dictionary.h39
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/core/variant/test_dictionary.h b/tests/core/variant/test_dictionary.h
index 7061bc66dc..48a48f6ca6 100644
--- a/tests/core/variant/test_dictionary.h
+++ b/tests/core/variant/test_dictionary.h
@@ -31,7 +31,7 @@
#ifndef TEST_DICTIONARY_H
#define TEST_DICTIONARY_H
-#include "core/variant/dictionary.h"
+#include "core/variant/typed_dictionary.h"
#include "tests/test_macros.h"
namespace TestDictionary {
@@ -536,6 +536,43 @@ TEST_CASE("[Dictionary] Order and find") {
CHECK_EQ(d.find_key("does not exist"), Variant());
}
+TEST_CASE("[Dictionary] Typed copying") {
+ TypedDictionary<int, int> d1;
+ d1[0] = 1;
+
+ TypedDictionary<double, double> d2;
+ d2[0] = 1.0;
+
+ Dictionary d3 = d1;
+ TypedDictionary<int, int> d4 = d3;
+
+ Dictionary d5 = d2;
+ TypedDictionary<int, int> d6 = d5;
+
+ d3[0] = 2;
+ d4[0] = 3;
+
+ // Same typed TypedDictionary should be shared.
+ CHECK_EQ(d1[0], Variant(3));
+ CHECK_EQ(d3[0], Variant(3));
+ CHECK_EQ(d4[0], Variant(3));
+
+ d5[0] = 2.0;
+ d6[0] = 3.0;
+
+ // Different typed TypedDictionary should not be shared.
+ CHECK_EQ(d2[0], Variant(2.0));
+ CHECK_EQ(d5[0], Variant(2.0));
+ CHECK_EQ(d6[0], Variant(3.0));
+
+ d1.clear();
+ d2.clear();
+ d3.clear();
+ d4.clear();
+ d5.clear();
+ d6.clear();
+}
+
} // namespace TestDictionary
#endif // TEST_DICTIONARY_H