diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-06 22:38:13 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-06 22:38:13 +0200 |
commit | 0b4ae20156c1597671a748192ed8c032ed1d053e (patch) | |
tree | ebb6b242506eb6697e34962cce83e49f3ad96ec9 /tests | |
parent | c9dc1eb1d59bf67bb123ed1ac5f9e0cfb93e275b (diff) | |
parent | 9853a691447cd4e279f48820067174d3833b0065 (diff) | |
download | redot-engine-0b4ae20156c1597671a748192ed8c032ed1d053e.tar.gz |
Merge pull request #78656 from Repiteo/typed-dictionary
Implement typed dictionaries
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/variant/test_dictionary.h | 39 |
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 |