ReactOS 0.4.15-dev-8231-g29a56f3
CSimpleMap.cpp File Reference
#include "atltest.h"
#include <atlbase.h>
#include <atlsimpcoll.h>
Include dependency graph for CSimpleMap.cpp:

Go to the source code of this file.

Classes

struct  CMonster
 

Functions

 START_TEST (CSimpleMap)
 

Function Documentation

◆ START_TEST()

START_TEST ( CSimpleMap  )

Definition at line 44 of file CSimpleMap.cpp.

45{
46 CSimpleMap<int, int> map1;
47
48 ok_int(map1.GetSize(), 0);
49
50 map1.Add(1, 2);
51 ok_int(map1.GetSize(), 1);
52 map1.Add(2, 3);
53 ok_int(map1.GetSize(), 2);
54
55 ok_int(map1.Lookup(1), 2);
56 ok_int(map1.Lookup(2), 3);
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
70 ok_int(map1.Lookup(1), 2);
71 ok_int(map1.Lookup(2), 4);
72
73 ok_int(map1.ReverseLookup(2), 1);
74 ok_int(map1.ReverseLookup(4), 2);
75
76 map1.Remove(1);
77 ok_int(map1.GetSize(), 1);
78 map1.Remove(2);
79 ok_int(map1.GetSize(), 0);
80
81 map1.Add(1, 4);
82 ok_int(map1.GetSize(), 1);
83 map1.Add(2, 8);
84 ok_int(map1.GetSize(), 2);
85 map1.Add(3, 12);
86 ok_int(map1.GetSize(), 3);
87
88 map1.RemoveAll();
89 ok_int(map1.GetSize(), 0);
90
93
94 CSimpleMap<CMonster, CMonster> map2;
95 ok_int(map2.GetSize(), 0);
96
99
100 {
101 CMonster m1;
104
105 CMonster m2;
108
109 map2.Add(m1, m2);
112 }
113
114 ok_int(map2.GetSize(), 1);
117
118 {
119 CMonster m1;
122
123 CMonster m2;
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
149 CMonster m3;
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(value,...)
Definition: atltest.h:57
#define ok_int(expression, result)
Definition: atltest.h:134
static int s_nCopyCount
Definition: CSimpleMap.cpp:20
static int s_nCount
Definition: CSimpleMap.cpp:19