#include "atltest.h"
#include <atlbase.h>
#include <atlsimpcoll.h>
Go to the source code of this file.
◆ START_TEST()
START_TEST |
( |
CSimpleMap |
| ) |
|
Definition at line 44 of file CSimpleMap.cpp.
45{
46 CSimpleMap<int, int> map1;
47
49
50 map1.Add(1, 2);
52 map1.Add(2, 3);
54
57 ok_int(map1.Lookup(-1), 0);
58
59 ok_int(map1.ReverseLookup(2), 1);
60 ok_int(map1.ReverseLookup(3), 2);
61
62 ok_int(map1.GetKeyAt(0), 1);
63 ok_int(map1.GetKeyAt(1), 2);
64
65 ok_int(map1.GetValueAt(0), 2);
66 ok_int(map1.GetValueAt(1), 3);
67
68 map1.SetAt(2, 4);
69
72
73 ok_int(map1.ReverseLookup(2), 1);
74 ok_int(map1.ReverseLookup(4), 2);
75
76 map1.Remove(1);
78 map1.Remove(2);
80
81 map1.Add(1, 4);
83 map1.Add(2, 8);
85 map1.Add(3, 12);
87
88 map1.RemoveAll();
90
93
94 CSimpleMap<CMonster, CMonster> map2;
96
99
100 {
104
108
109 map2.Add(m1, m2);
112 }
113
114 ok_int(map2.GetSize(), 1);
117
118 {
122
126
127 map2.Add(m1, m2);
130 }
131
132 ok_int(map2.GetSize(), 2);
135
136 map2.RemoveAt(0);
138 ok_int(map2.GetSize(), 1);
140
141 map2.RemoveAt(0);
143 ok_int(map2.GetSize(), 0);
145
146 CSimpleMap<int, CMonster> map3;
147 ok_int(map3.GetSize(), 0);
148
151
152 map3.Add(1, m3);
153 ok_int(map3.GetSize(), 1);
155
156 map3.Add(2, m3);
157 ok_int(map3.GetSize(), 2);
159
160 map3.Add(3, m3);
161 ok_int(map3.GetSize(), 3);
163
164 map3.Remove(2);
165 ok_int(map3.GetSize(), 2);
167
168 map3.RemoveAll();
169 ok_int(map3.GetSize(), 0);
171
172 map1.Add(1, 2);
173 ok_int(map1.GetSize(), 1);
174 map1.Add(2, 3);
175 ok_int(map1.GetSize(), 2);
176
177 ok(!!map1.RemoveAt(0),
"Expected RemoveAt(0) to succeed\n");
178 ok_int(map1.GetSize(), 1);
179 ok(!!map1.RemoveAt(0),
"Expected RemoveAt(0) to succeed\n");
180 ok_int(map1.GetSize(), 0);
181}
#define ok_int(expression, result)