-
Notifications
You must be signed in to change notification settings - Fork 0
/
Map_tests.cpp
63 lines (53 loc) · 1.07 KB
/
Map_tests.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "Map.h"
#include "unit_test_framework.h"
#include <iostream>
#include <utility>
using namespace std;
TEST(test_map_size) {
Map<int, int> map;
map[0];
map[1];
ASSERT_EQUAL(map.size(), 2);
}
TEST(test_map_key_value_pair) {
Map<int, int> map;
map[0] = 1;
ASSERT_EQUAL(map[0], 1);
}
TEST(test_map_unique_keys) {
Map<int, int> map;
map[0] = 1;
map[0] = 2;
ASSERT_EQUAL(map.size(), 1);
}
TEST(test_map_contains) {
Map<int, int> map;
map[0];
ASSERT_TRUE(map.contains(0));
ASSERT_FALSE(map.contains(1));
}
TEST(test_map_clear) {
Map<int, int> map;
map[0] = 100;
map.clear();
ASSERT_EQUAL(map.size(), 0);
}
TEST(test_map_grow) {
Map<int, int> map;
map[0];
map[1];
map[2];
ASSERT_EQUAL(map.size(), 3);
}
TEST(test_map_iteration) {
Map<int, int> map;
map[0] = 10;
map[1] = 11;
map[2] = 12;
for (auto it = map.begin(); it != map.end(); ++it) {
pair<int, int> entry = *it;
cout << entry.first << ":" << entry.second << " ";
}
cout << endl;
}
TEST_MAIN()