Skip to content

Commit

Permalink
More test
Browse files Browse the repository at this point in the history
  • Loading branch information
aslze committed Jun 9, 2024
1 parent 0ed8190 commit 0d328f1
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions tests/unittests2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,21 @@ ASL_TEST(Path)

ASL_TEST(HashMap)
{
HashDic<int> dic;
for(int i=0; i<10; i++)
dic[10-i] = i;
ASL_ASSERT(dic.length() == 10);
HashDic<int> 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<int, float> m;
m[100] = 125.0f;
Expand All @@ -324,6 +329,23 @@ String join(const Dic<int>& a)

ASL_TEST(Map)
{
Map<int, int> 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<int, String> numbers;
numbers[12] = "twelve";
numbers[-2] = "minus two";
Expand Down

0 comments on commit 0d328f1

Please sign in to comment.