-
Notifications
You must be signed in to change notification settings - Fork 284
Expand file tree
/
Copy pathdeque_map.test.cpp
More file actions
67 lines (60 loc) · 1.68 KB
/
Copy pathdeque_map.test.cpp
File metadata and controls
67 lines (60 loc) · 1.68 KB
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
64
65
66
67
#include <iostream>
#include <algorithm>
#include "external/minunit.h"
#include "deque_map.h"
MU_TEST(test_deque_map) {
DequeMap<std::string> strs;
mu_check(strs.size() == 0);
mu_check(!strs.full());
mu_check(strs.find("foo") == -1);
mu_check(strs.add("foo") == 0);
mu_check(!strs.full());
mu_check(strs.find("foo") == 0);
mu_check(strs.size() == 1);
mu_check(strs.add("foo") == 0);
mu_check(strs.size() == 1);
mu_check(strs.add("bar") == 1);
mu_check(strs.size() == 2);
mu_check(strs.add("aardvark") == 2);
mu_check(strs.size() == 3);
mu_check(strs.add("foo") == 0);
mu_check(strs.add("bar") == 1);
mu_check(strs.add("quux") == 3);
mu_check(strs.size() == 4);
mu_check(strs.at(0) == "foo");
mu_check(strs[0] == "foo");
mu_check(strs.at(1) == "bar");
mu_check(strs[1] == "bar");
mu_check(strs.at(2) == "aardvark");
mu_check(strs[2] == "aardvark");
mu_check(strs.at(3) == "quux");
mu_check(strs[3] == "quux");
std::vector<std::string> rv;
for (std::string x : strs) {
rv.push_back(x);
}
mu_check(rv[0] == "aardvark");
mu_check(rv[1] == "bar");
mu_check(rv[2] == "foo");
mu_check(rv[3] == "quux");
DequeMap<std::string> boundedMap(1);
mu_check(!boundedMap.full());
mu_check(boundedMap.add("foo") == 0);
mu_check(boundedMap.add("foo") == 0);
mu_check(boundedMap.full());
mu_check(boundedMap.add("bar") == -1);
boundedMap.clear();
mu_check(!boundedMap.full());
mu_check(boundedMap.find("foo") == -1);
mu_check(boundedMap.add("bar") == 0);
mu_check(boundedMap.add("bar") == 0);
mu_check(boundedMap.full());
}
MU_TEST_SUITE(test_suite_deque_map) {
MU_RUN_TEST(test_deque_map);
}
int main() {
MU_RUN_SUITE(test_suite_deque_map);
MU_REPORT();
return MU_EXIT_CODE;
}