From cc424bcb18585f09148d12e28f8d4b9f54c8445d Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 5 Aug 2022 19:08:27 +0200 Subject: Add Dictionary.find_key() --- tests/core/variant/test_dictionary.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/core') diff --git a/tests/core/variant/test_dictionary.h b/tests/core/variant/test_dictionary.h index 729035919d..c98434d42c 100644 --- a/tests/core/variant/test_dictionary.h +++ b/tests/core/variant/test_dictionary.h @@ -500,6 +500,24 @@ TEST_CASE("[Dictionary] Recursive self comparison") { d2.clear(); } +TEST_CASE("[Dictionary] Order and find") { + Dictionary d; + d[4] = "four"; + d[8] = "eight"; + d[12] = "twelve"; + d["4"] = "four"; + + Array keys; + keys.append(4); + keys.append(8); + keys.append(12); + keys.append("4"); + + CHECK_EQ(d.keys(), keys); + CHECK_EQ(d.find_key("four"), Variant(4)); + CHECK_EQ(d.find_key("does not exist"), Variant()); +} + } // namespace TestDictionary #endif // TEST_DICTIONARY_H -- cgit v1.2.3