blob: 0820cd9c425509b61a97e345d81e75415b96493a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include "TestHelpers.h"
#include <AK/AKString.h>
#include <AK/HashMap.h>
typedef HashMap<int, int> IntIntMap;
int main()
{
EXPECT(IntIntMap().is_empty());
EXPECT(IntIntMap().size() == 0);
HashMap<int, String> number_to_string;
number_to_string.set(1, "One");
number_to_string.set(2, "Two");
number_to_string.set(3, "Three");
EXPECT_EQ(number_to_string.is_empty(), false);
EXPECT_EQ(number_to_string.size(), 3);
int loop_counter = 0;
for (auto& it : number_to_string) {
EXPECT(!it.value.is_null());
++loop_counter;
}
number_to_string.remove(1);
EXPECT_EQ(number_to_string.size(), 2);
EXPECT(number_to_string.find(1) == number_to_string.end());
number_to_string.remove(3);
EXPECT_EQ(number_to_string.size(), 1);
EXPECT(number_to_string.find(3) == number_to_string.end());
EXPECT_EQ(loop_counter, 3);
return 0;
}
|