103 {
104
105 long int a = 12341;
106 long double b = 3352.9933;
107
108 cout << "\n\n\n==========================================================\n";
109 cout << "Testing the VariableMap Class\n";
110 cout << "==========================================================\n";
111
112
113 cout << "\n\n\n==========================================================\n";
114 cout << "Testing basic encoding\n";
115 cout << "==========================================================\n";
116
118
119 Variant myVariant1(34); cout <<
"." << flush;
120 Variant myVariant2(33.5252); cout <<
"." << flush;
121 Variant myVariant3(0); cout <<
"." << flush;
122 int i;
123
124 myVMap.
AddVariable(
"one", myVariant1); cout <<
"." << flush;
125 myVMap.
AddVariable(
"two", myVariant2); cout <<
"." << flush;
126 myVMap.
AddVariable(
"three", myVariant3); cout <<
"." << flush;
127 myVMap.
AddVariable(
"four", myVariant1); cout <<
"." << flush;
128
129
130 cout << "\n\n\n==========================================================\n";
131 cout << "Testing basic retreival\n";
132 cout << "==========================================================\n";
133
135 cout << " Retrieved one: " << myVariant3 << endl;
137 cout << " Retrieved two: " << myVariant3 << endl;
139 cout << " Retrieved three: " << myVariant3 << endl;
141 cout << " Retrieved four: " << myVariant3 << endl;
142
143
144 cout << "\n\n\n==========================================================\n";
145 cout << "Testing overwriting\n";
146 cout << "==========================================================\n";
147
148
152 myVMap.
AddVariable(
"four", myVariant2+ myVariant1);
153
154
156 cout << " Retrieved one: " << myVariant3 << endl;
158 cout << " Retrieved two: " << myVariant3 << endl;
160 cout << " Retrieved three: " << myVariant3 << endl;
162 cout << " Retrieved four: " << myVariant3 << endl;
163
164
165
166 cout << "\n\n\n==========================================================\n";
167 cout << "Testing retrieval of undefined\n";
168 cout << "==========================================================\n";
169
171 cout << " Retrieved oney: " << myVariant3 << endl;
173 cout << " Retrieved TWO: " << myVariant3 << endl;
175 cout << " Retrieved about: " << myVariant3 << endl;
177 cout << " Retrieved something: " << myVariant3 << endl;
178
179 cout << "\n\n\n==========================================================\n";
180 cout << "Testing DumpValues Method\n";
181 cout << "==========================================================\n";
182
184
185
186 cout << "\n\n\n==========================================================\n";
187 cout << "Performance test: 1000000 reencodings\n";
188 cout << "==========================================================\n";
189
190 for(i = 0; i<1000000; i++)
191 {
193 if(i%1000==0) cout << "." << flush;
194 }
195 cout << "Finished 1000000 reencodings" << endl;
196
197
198
199
200 cout << "\n\n\n==========================================================\n";
201 cout << "Performance test: 1000000 reencodings with creation of new Variant\n";
202 cout << "==========================================================\n";
203
204 for(i = 0; i<1000000; i++)
205 {
207 if(i%1000==0) cout << "." << flush;
208 }
209 cout << "Finished 1000000 reencodings" << endl;
210
211
212
213 cout << "\n\n\n==========================================================\n";
214 cout << "Performance test: 1000000 retrievals\n";
215 cout << "==========================================================\n";
216
217 for(i = 0; i<1000000; i++)
218 {
220 if(i%1000==0) cout << "." << flush;
221 }
222 cout << "Finished 1000000 retrievals" << endl;
223
224
225
226 cout << "\n\n\n==========================================================\n";
227 cout << "Performance test: 1000000 Unique encodings\n";
228 cout << "==========================================================\n";
229
230 char name[20];
231 for(i = 0; i<1000000; i++)
232 {
233
234 sprintf(name, "%10d",i);
235
237 if(i%1000==0) cout << "." << flush;
238 }
239 cout << "Finished 1000000 Unique encodings" << endl;
240
241
242
243 cout << "\n\n\n==========================================================\n";
244 cout << "Performance test: 1000000 Unique retrievals\n";
245 cout << "==========================================================\n";
246
247
248 for(i = 999999; i>=0; i--)
249 {
250 sprintf(name, "%10d",i);
252 if(i%1000==0) cout << "." << flush;
253 }
254 cout << "Finished 1000000 Unique retrievals" << endl;
255
256
257 cout << "\n\n\n==========================================================\n";
258 cout << "Performance test: 100000 Unique erases\n";
259 cout << "==========================================================\n";
260
261
262 for(i = 999999; i>=0; i--)
263 {
264 sprintf(name, "%10d",i);
266 if(i%1000==0) cout << "." << flush;
267 }
268 cout << "Finished 1000000 Unique retrievals" << endl;
269
270
271 cout << "==========================================================\n";
272 cout << "Dumping Remaining Values:" << endl;
273 cout << "==========================================================\n";
275
276
277
278
279 cout << "\n\n\n==========================================================\n";
280 cout << "Testing basic retrieval Again\n";
281 cout << "==========================================================\n";
282
284 cout << " Retrieved one: " << myVariant3 << endl;
286 cout << " Retrieved two: " << myVariant3 << endl;
288 cout << " Retrieved three: " << myVariant3 << endl;
290 cout << " Retrieved four: " << myVariant3 << endl;
291
292
293
294
295 cout << "==========================================================\n";
296 cout << "Finished Variable Map Tests" << endl;
297 cout << "==========================================================\n";
298 cout << "==========================================================\n";
299 cout << "==========================================================\n";
300 cout << "==========================================================\n";
301 cout << "==========================================================\n";
302 return 0;
303}
void Erase(const std::string &varname)
void AddVariable(const std::string &varname, const Variant &val)
Variant RetrieveValue(const std::string &varname)