mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Merge pull request #104047 from YYF233333/dict_iter
Add const iteration support to `Dictionary`
This commit is contained in:
@@ -593,4 +593,21 @@ TEST_CASE("[Dictionary] Typed copying") {
|
||||
d6.clear();
|
||||
}
|
||||
|
||||
TEST_CASE("[Dictionary] Iteration") {
|
||||
Dictionary a1 = build_dictionary(1, 2, 3, 4, 5, 6);
|
||||
Dictionary a2 = build_dictionary(1, 2, 3, 4, 5, 6);
|
||||
|
||||
int idx = 0;
|
||||
|
||||
for (const KeyValue<Variant, Variant> &kv : (const Dictionary &)a1) {
|
||||
CHECK_EQ(int(a2[kv.key]), int(kv.value));
|
||||
idx++;
|
||||
}
|
||||
|
||||
CHECK_EQ(idx, a1.size());
|
||||
|
||||
a1.clear();
|
||||
a2.clear();
|
||||
}
|
||||
|
||||
} // namespace TestDictionary
|
||||
|
||||
Reference in New Issue
Block a user