Add missing initializer_list constructor for TypedDictionary

This commit is contained in:
Tom
2025-03-26 19:01:56 +00:00
parent 1f56d96cf2
commit 8a3f9846c5
3 changed files with 35 additions and 0 deletions

View File

@@ -606,4 +606,28 @@ TEST_CASE("[Dictionary] Iteration") {
a2.clear();
}
TEST_CASE("[Dictionary] Object value init") {
Object *a = memnew(Object);
Object *b = memnew(Object);
TypedDictionary<double, Object *> tdict = {
{ 0.0, a },
{ 5.0, b },
};
CHECK_EQ(tdict[0.0], Variant(a));
CHECK_EQ(tdict[5.0], Variant(b));
memdelete(a);
memdelete(b);
}
TEST_CASE("[Dictionary] RefCounted value init") {
Ref<RefCounted> a = memnew(RefCounted);
Ref<RefCounted> b = memnew(RefCounted);
TypedDictionary<double, Ref<RefCounted>> tdict = {
{ 0.0, a },
{ 5.0, b },
};
CHECK_EQ(tdict[0.0], Variant(a));
CHECK_EQ(tdict[5.0], Variant(b));
}
} // namespace TestDictionary