From 0d328f1229b2ec6d0d9f591f74b928f63c4c918d Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sun, 9 Jun 2024 17:01:27 +0200 Subject: [PATCH] More test --- tests/unittests2.cpp | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/tests/unittests2.cpp b/tests/unittests2.cpp index c0c40cf..cbe7a94 100644 --- a/tests/unittests2.cpp +++ b/tests/unittests2.cpp @@ -288,16 +288,21 @@ ASL_TEST(Path) ASL_TEST(HashMap) { - HashDic dic; - for(int i=0; i<10; i++) - dic[10-i] = i; - ASL_ASSERT(dic.length() == 10); + HashDic map; + for(int i=0; i<100; i++) + map[100 - i] = i; + ASL_ASSERT(map.length() == 100); - for(int i=0; i<10; i++) - ASL_ASSERT(dic[10-i] == i); - dic.clear(); + for(int i=0; i<100; i++) + ASL_ASSERT(map[100 - i] == i); - ASL_ASSERT(dic.length() == 0); + int* p = map.find(50); + ASL_ASSERT(map.has(50) && p != NULL && *p == 50); + ASL_ASSERT(!map.has(-5) && !map.find(-5)); + + map.clear(); + + ASL_ASSERT(map.length() == 0); HashMap m; m[100] = 125.0f; @@ -324,6 +329,23 @@ String join(const Dic& a) ASL_TEST(Map) { + Map map; + for (int i = 0; i < 100; i++) + map[100 - i] = i; + + ASL_ASSERT(map.length() == 100); + + for (int i = 0; i < 100; i++) + ASL_ASSERT(map[100 - i] == i); + + int* p = map.find(50); + ASL_ASSERT(map.has(50) && p != NULL && *p == 50); + ASL_ASSERT(!map.has(-5) && !map.find(-5)); + + map.clear(); + + ASL_ASSERT(map.length() == 0); + Map numbers; numbers[12] = "twelve"; numbers[-2] = "minus two";