autoc 0.8 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/README +15 -4
  3. data/doc/AutoC.html +245 -0
  4. data/doc/AutoC/Code.html +520 -0
  5. data/doc/AutoC/Collection.html +923 -0
  6. data/doc/AutoC/HashMap.html +1161 -0
  7. data/doc/AutoC/HashSet.html +1122 -0
  8. data/doc/AutoC/List.html +1002 -0
  9. data/doc/AutoC/Module.html +951 -0
  10. data/doc/AutoC/Module/File.html +412 -0
  11. data/doc/AutoC/Module/Header.html +432 -0
  12. data/doc/AutoC/Module/Source.html +704 -0
  13. data/doc/AutoC/Priority.html +138 -0
  14. data/doc/AutoC/Queue.html +1167 -0
  15. data/doc/AutoC/Type.html +1152 -0
  16. data/doc/AutoC/UserDefinedType.html +655 -0
  17. data/doc/AutoC/Vector.html +856 -0
  18. data/doc/_index.html +299 -0
  19. data/doc/class_list.html +54 -0
  20. data/doc/css/common.css +1 -0
  21. data/doc/css/full_list.css +57 -0
  22. data/doc/css/style.css +339 -0
  23. data/doc/file.README.html +112 -0
  24. data/doc/file_list.html +56 -0
  25. data/doc/frames.html +26 -0
  26. data/doc/index.html +112 -0
  27. data/doc/js/app.js +219 -0
  28. data/doc/js/full_list.js +178 -0
  29. data/doc/js/jquery.js +4 -0
  30. data/doc/method_list.html +605 -0
  31. data/doc/top-level-namespace.html +112 -0
  32. data/lib/autoc.rb +35 -12
  33. data/lib/autoc/{code_builder.rb → code.rb} +230 -247
  34. data/lib/autoc/collection.rb +137 -0
  35. data/lib/autoc/collection/hash_map.rb +388 -0
  36. data/lib/autoc/collection/hash_set.rb +433 -0
  37. data/lib/autoc/collection/list.rb +410 -0
  38. data/lib/autoc/collection/queue.rb +514 -0
  39. data/lib/autoc/collection/vector.rb +295 -0
  40. data/lib/autoc/type.rb +198 -0
  41. data/test/test.c +921 -396
  42. data/test/test.h +41 -0
  43. data/test/test.rb +21 -26
  44. data/test/test_auto.c +2630 -3961
  45. data/test/test_auto.h +449 -560
  46. metadata +50 -17
  47. data/lib/autoc/data_struct_builder.rb +0 -1794
  48. data/lib/autoc/type_builder.rb +0 -24
  49. data/manual/manual.pdf +0 -0
data/test/test.c CHANGED
@@ -1,396 +1,921 @@
1
- #include <assert.h>
2
- #include <stdio.h>
3
- #include <string.h>
4
-
5
-
6
- #include "test_auto.h"
7
-
8
-
9
- void PrintIntVector(IntVector* vec) {
10
- IntVectorIt it;
11
- IntVectorItCtor(&it, vec);
12
- while(IntVectorItHasNext(&it)) {
13
- printf("%d ", IntVectorItNext(&it));
14
- }
15
- printf("\n");
16
- }
17
-
18
-
19
- void IntVectorTest() {
20
- IntVector* vec;
21
- printf("\n*** IntVector\n");
22
- vec = IntVectorAssign(IntVectorNew(10));
23
- printf("size = %d\n", IntVectorSize(vec));
24
- IntVectorSet(vec, 0, 3);
25
- IntVectorSet(vec, 1, 11);
26
- IntVectorSet(vec, 2, 4);
27
- IntVectorSet(vec, 3, 0);
28
- IntVectorSet(vec, 4, 5);
29
- IntVectorSet(vec, 5, 99);
30
- IntVectorSet(vec, 6, 2);
31
- IntVectorSet(vec, 7, 7);
32
- IntVectorSet(vec, 8, 6);
33
- IntVectorSet(vec, 9, 8);
34
- PrintIntVector(vec);
35
- printf("vec[0] == %d\n", IntVectorGet(vec, 0));
36
- IntVectorSort(vec);
37
- PrintIntVector(vec);
38
- IntVectorDestroy(vec);
39
- }
40
-
41
-
42
- void IntSetTest() {
43
- IntSet set;
44
- IntSetIt it;
45
- printf("\n*** IntSet\n");
46
- IntSetCtor(&set);
47
- printf("size = %d\n", IntSetSize(&set));
48
- IntSetPut(&set, -1);
49
- IntSetPut(&set, 3);
50
- IntSetPut(&set, 0);
51
- IntSetPut(&set, 3);
52
- printf("size = %d\n", IntSetSize(&set));
53
- IntSetPut(&set, 7);
54
- printf("size = %d\n", IntSetSize(&set));
55
- IntSetItCtor(&it, &set);
56
- while(IntSetItHasNext(&it)) {
57
- printf("- %d\n", IntSetItNext(&it));
58
- }
59
- IntSetDtor(&set);
60
- }
61
-
62
-
63
- size_t PCharHash(const char* s) {
64
- size_t h = 0;
65
- while(*s++) {
66
- h += *s;
67
- }
68
- return h;
69
- }
70
-
71
-
72
- int PCharEqual(const char* lt, const char* rt) {
73
- return strcmp(lt, rt) == 0;
74
- }
75
-
76
-
77
- void PrintPCharSet(PCharSet* set) {
78
- PCharSetIt it;
79
- PCharSetItCtor(&it, set);
80
- while(PCharSetItHasNext(&it)) {
81
- printf("%s ", PCharSetItNext(&it));
82
- }
83
- printf("\n");
84
- }
85
-
86
-
87
- void PCharSetTest() {
88
- PCharSet set;
89
- PCharSetIt it;
90
- printf("\n*** PCharSet (I)\n");
91
- PCharSetCtor(&set);
92
- printf("size = %d\n", PCharSetSize(&set));
93
- PCharSetPut(&set, "cat");
94
- PCharSetPut(&set, "dog");
95
- PCharSetPut(&set, "cat");
96
- printf("size = %d\n", PCharSetSize(&set));
97
- PCharSetPut(&set, "pig");
98
- printf("size = %d\n", PCharSetSize(&set));
99
- PCharSetItCtor(&it, &set);
100
- while(PCharSetItHasNext(&it)) {
101
- printf("- %s\n", PCharSetItNext(&it));
102
- }
103
- printf("contains(pig) == %d\n", PCharSetContains(&set, "pig"));
104
- printf("contains(snake) == %d\n", PCharSetContains(&set, "snake"));
105
- PCharSetPurge(&set);
106
- PCharSetDtor(&set);
107
- }
108
-
109
-
110
- void PCharSetTest2() {
111
- PCharSet *a, *b, *c;
112
- printf("\n*** PCharSet (II)\n");
113
- a = PCharSetAssign(PCharSetNew());
114
- b = PCharSetAssign(PCharSetNew());
115
- c = PCharSetAssign(PCharSetNew());
116
- PCharSetPut(a, "cat");
117
- PCharSetPut(a, "dog");
118
- PCharSetPut(a, "pig");
119
- PCharSetPut(a, "rat");
120
- PCharSetPut(b, "mouse");
121
- PCharSetPut(b, "snake");
122
- PCharSetPut(b, "rat");
123
-
124
- PCharSetPurge(c);
125
- PCharSetOr(c, a);
126
- PCharSetAnd(c, b);
127
- PrintPCharSet(c);
128
-
129
- PCharSetPurge(c);
130
- PCharSetOr(c, a);
131
- PCharSetOr(c, b);
132
- PrintPCharSet(c);
133
-
134
- PCharSetPurge(c);
135
- PCharSetOr(c, a);
136
- PCharSetXor(c, b);
137
- PrintPCharSet(c);
138
-
139
- PCharSetDestroy(a);
140
- PCharSetDestroy(b);
141
- PCharSetDestroy(c);
142
- }
143
-
144
-
145
- void PChar2IntMapTest() {
146
- PChar2IntMap* map;
147
- PChar2IntMapIt it;
148
- printf("\n*** PChar2IntMap\n");
149
- map = PChar2IntMapAssign(PChar2IntMapNew());
150
- PChar2IntMapPut(map, "cat", 1);
151
- PChar2IntMapPut(map, "dog", 2);
152
- PChar2IntMapPut(map, "cat", 0);
153
- PChar2IntMapPut(map, "pig", 0);
154
- printf("size = %d\n", PChar2IntMapSize(map));
155
- PChar2IntMapItCtor(&it, map);
156
- while(PChar2IntMapItHasNext(&it)) {
157
- PChar2IntMapEntry entry = PChar2IntMapItNext(&it);
158
- printf("- %s --> %d\n", entry.key, entry.value);
159
- }
160
- PChar2IntMapPurge(map);
161
- PChar2IntMapDestroy(map);
162
- }
163
-
164
-
165
- struct Box {
166
- size_t refs;
167
- int contents;
168
- };
169
-
170
-
171
- Box* BoxNew() {
172
- Box* box = (Box*)malloc(sizeof(Box));
173
- box->refs = 0;
174
- box->contents = -1;
175
- return box;
176
- }
177
-
178
-
179
- Box* BoxMake(int contents) {
180
- Box* box = BoxNew();
181
- box->contents = contents;
182
- return box;
183
- }
184
-
185
-
186
- Box* BoxAssign(Box* box) {
187
- assert(box);
188
- ++box->refs;
189
- return box;
190
- }
191
-
192
-
193
- int BoxEqual(Box* lt, Box* rt) {
194
- assert(lt);
195
- assert(rt);
196
- return lt->contents == rt->contents;
197
- }
198
-
199
-
200
- size_t BoxHash(Box* box) {
201
- assert(box);
202
- return box->contents;
203
- }
204
-
205
-
206
- void BoxDestroy(Box* box) {
207
- assert(box);
208
- if(!--box->refs) free(box);
209
- }
210
-
211
-
212
- void BoxSetTest() {
213
- int i;
214
- BoxSet* set;
215
- Box *b1, *b2, *b4;
216
- printf("\n*** BoxSet\n");
217
- b1 = BoxAssign(BoxMake(1));
218
- b2 = BoxAssign(BoxMake(2));
219
- b4 = BoxAssign(b2);
220
- set = BoxSetAssign(BoxSetNew());
221
- BoxSetPut(set, b1);
222
- BoxSetPut(set, BoxMake(3));
223
- BoxSetPut(set, b2);
224
- BoxSetPut(set, b1);
225
- printf("size = %d\n", BoxSetSize(set));
226
- BoxDestroy(b1);
227
- for(i = 0; i < 100; ++i) {
228
- BoxSetPut(set, BoxMake(i));
229
- }
230
- printf("size = %d\n", BoxSetSize(set));
231
- BoxSetPurge(set);
232
- BoxSetDestroy(set);
233
- BoxDestroy(b2);
234
- BoxDestroy(b4);
235
- }
236
-
237
-
238
- void BoxVectorTest() {
239
- BoxVector* vec;
240
- Box* b1;
241
- printf("\n*** BoxVector\n");
242
- b1 = BoxAssign(BoxNew());
243
- vec = BoxVectorAssign(BoxVectorNew(10));
244
- printf("size = %d\n", BoxVectorSize(vec));
245
- BoxVectorSet(vec, 7, b1);
246
- BoxVectorResize(vec, 5);
247
- printf("size = %d\n", BoxVectorSize(vec));
248
- BoxVectorSet(vec, 3, BoxNew());
249
- BoxVectorResize(vec, 10);
250
- printf("size = %d\n", BoxVectorSize(vec));
251
- BoxVectorDestroy(vec);
252
- BoxDestroy(b1);
253
- }
254
-
255
-
256
- void BoxListTest() {
257
- BoxList* list;
258
- Box *b1,*b2;
259
- printf("\n*** BoxList\n");
260
- list = BoxListAssign(BoxListNew());
261
- b1 = BoxAssign(BoxNew());
262
- BoxListAdd(list, BoxMake(2));
263
- BoxListAdd(list, BoxMake(1));
264
- printf("size = %d\n", BoxListSize(list));
265
- printf("contains([-1]) == %d\n", BoxListContains(list, b1));
266
- BoxListChop(list);
267
- BoxListRemove(list, BoxMake(1));
268
- BoxListRemove(list, BoxMake(2));
269
- BoxListRemove(list, BoxMake(3));
270
- printf("size = %d\n", BoxListSize(list));
271
- BoxListPurge(list);
272
- BoxListAdd(list, BoxMake(7));
273
- BoxListAdd(list, b1);
274
- BoxListAdd(list, b1);
275
- b2 = BoxAssign(BoxMake(3));
276
- printf("size = %d\n", BoxListSize(list));
277
- printf("contains([-1]) == %d\n", BoxListContains(list, b1));
278
- BoxListReplaceAll(list, b1, b2);
279
- printf("contains([-1]) == %d\n", BoxListContains(list, b1));
280
- printf("contains([3]) == %d\n", BoxListContains(list, b2));
281
- BoxListChop(list);
282
- printf("size = %d\n", BoxListSize(list));
283
- BoxListDestroy(list);
284
- BoxDestroy(b1);
285
- BoxDestroy(b2);
286
- }
287
-
288
-
289
- void Box2BoxMapTest() {
290
- int i;
291
- Box2BoxMap* map, *map2;
292
- Box *b1, *b2;
293
- printf("\n*** Box2BoxMap\n");
294
- map = Box2BoxMapAssign(Box2BoxMapNew());
295
- b1 = BoxAssign(BoxMake(-1));
296
- b2 = BoxAssign(b1);
297
- Box2BoxMapContainsKey(map, BoxMake(3));
298
- Box2BoxMapContainsKey(map, b1);
299
- Box2BoxMapReplace(map, BoxMake(-1), BoxMake(-1));
300
- Box2BoxMapReplace(map, BoxMake(-2), BoxMake(-2));
301
- Box2BoxMapPut(map, b1, BoxMake(3));
302
- Box2BoxMapPut(map, BoxMake(2), BoxMake(2));
303
- Box2BoxMapPut(map, BoxMake(1), BoxMake(1));
304
- Box2BoxMapReplace(map, BoxMake(1), BoxMake(-3));
305
- printf("size = %d\n", Box2BoxMapSize(map));
306
- for(i = 0; i < 100; ++i) {
307
- Box2BoxMapPut(map, BoxMake(i), BoxMake(-i));
308
- }
309
- printf("size = %d\n", Box2BoxMapSize(map));
310
- i = -2; printf("map[Box(%d)] == Box(%d)\n", i, Box2BoxMapGet(map, BoxMake(i))->contents);
311
- i = 3; printf("map[Box(%d)] == Box(%d)\n", i, Box2BoxMapGet(map, BoxMake(i))->contents);
312
- printf("contains([99]) == %d\n", Box2BoxMapContainsKey(map, BoxMake(+99)));
313
- Box2BoxMapRemove(map, BoxMake(+99));
314
- printf("contains([99]) == %d\n", Box2BoxMapContainsKey(map, BoxMake(+99)));
315
- map2 = Box2BoxMapAssign(map);
316
- Box2BoxMapRemove(map2, BoxMake(-99));
317
- Box2BoxMapPurge(map);
318
- Box2BoxMapPut(map2, BoxMake(3), b2);
319
- BoxDestroy(b2);
320
- printf("size = %d\n", Box2BoxMapSize(map2));
321
- Box2BoxMapDestroy(map2);
322
- Box2BoxMapDestroy(map);
323
- BoxDestroy(b1);
324
- }
325
-
326
-
327
- void PChar2IntVectorMapTest() {
328
- size_t i;
329
- PChar2IntVectorMap* map;
330
- IntVector* vec;
331
- printf("\n*** PChar2IntVectorMap\n");
332
- map = PChar2IntVectorMapAssign(PChar2IntVectorMapNew());
333
- PChar2IntVectorMapPut(map, "zero", IntVectorNew(3));
334
- PChar2IntVectorMapPut(map, "one", IntVectorNew(3));
335
- vec = PChar2IntVectorMapGet(map, "one"); for(i = 0; i < IntVectorSize(vec); ++i) {
336
- IntVectorSet(vec, i, i);
337
- }
338
- printf("size = %d\n", IntVectorSize(vec));
339
- PrintIntVector(vec);
340
- IntVectorResize(PChar2IntVectorMapGet(map, "one"), 5);
341
- printf("size = %d\n", IntVectorSize(vec));
342
- PrintIntVector(vec);
343
- PChar2IntVectorMapDestroy(map);
344
- }
345
-
346
-
347
- void PrintPCharQueue(PCharQueue* queue, int fwd) {
348
- PCharQueueIt it;
349
- PCharQueueItCtor(&it, queue, fwd);
350
- while(PCharQueueItHasNext(&it)) {
351
- printf("%s ", PCharQueueItNext(&it));
352
- }
353
- printf("\n");
354
- }
355
-
356
-
357
- void PCharQueueTest() {
358
- PCharQueue* queue;
359
- printf("\n*** PCharQueue\n");
360
- queue = PCharQueueAssign(PCharQueueNew());
361
- PCharQueuePrepend(queue, "one");
362
- PCharQueuePrepend(queue, "zero");
363
- PCharQueueAppend(queue, "two");
364
- PCharQueueAppend(queue, "three");
365
- printf("contains(zero) == %d\n", PCharQueueContains(queue, "zero"));
366
- printf("contains(four) == %d\n", PCharQueueContains(queue, "four"));
367
- PrintPCharQueue(queue, 1);
368
- PrintPCharQueue(queue, 0);
369
- PCharQueueRemove(queue, "two");
370
- printf("head = %s\n", PCharQueueHead(queue));
371
- printf("tail = %s\n", PCharQueueTail(queue));
372
- PCharQueueChopTail(queue);
373
- PCharQueueChopHead(queue);
374
- PrintPCharQueue(queue, 1);
375
- PCharQueuePurge(queue);
376
- PCharQueueAppend(queue, "zero");
377
- printf("head = %s\n", PCharQueueHead(queue));
378
- printf("tail = %s\n", PCharQueueTail(queue));
379
- PCharQueueDestroy(queue);
380
- }
381
-
382
-
383
- int main(int argc, char** argv) {
384
- IntVectorTest();
385
- IntSetTest();
386
- PCharSetTest();
387
- PCharSetTest2();
388
- PChar2IntMapTest();
389
- BoxSetTest();
390
- BoxVectorTest();
391
- BoxListTest();
392
- Box2BoxMapTest();
393
- PChar2IntVectorMapTest();
394
- PCharQueueTest();
395
- return 0;
396
- }
1
+ /*
2
+ * This test is intended to be run under memory debugger such as Valgrind or Dr.Memory.
3
+ * Normally it should complete without errors and should exhibit no memory-related issues.
4
+ * The test should be compilable with any ANSI C compiler.
5
+ *
6
+ * > cc test.c test_auto.c
7
+ */
8
+
9
+
10
+ #include <assert.h>
11
+ #include <memory.h>
12
+ #include <stdio.h>
13
+
14
+
15
+ #include "test.h"
16
+ #include "test_auto.h"
17
+
18
+
19
+ #define SIZE 16
20
+ void ValueTypeCtorEx(ValueType* self, int value) {
21
+ assert(self);
22
+ self->value = value;
23
+ self->block = malloc(SIZE); assert(self->block);
24
+ }
25
+
26
+
27
+ void ValueTypeCtorRef(ValueType* self) {
28
+ ValueTypeCtorEx(self, 0);
29
+ }
30
+
31
+
32
+ void ValueTypeDtorRef(ValueType* self) {
33
+ assert(self);
34
+ free(self->block);
35
+ }
36
+
37
+
38
+ void ValueTypeCopyRef(ValueType* dst, ValueType* src) {
39
+ assert(src);
40
+ assert(dst);
41
+ dst->block = malloc(SIZE); assert(dst->block);
42
+ dst->value = src->value;
43
+ memcpy(dst->block, src->block, SIZE);
44
+ }
45
+
46
+
47
+ int ValueTypeEqualRef(ValueType* lt, ValueType* rt) {
48
+ assert(lt);
49
+ assert(rt);
50
+ return lt->value == rt->value;
51
+ }
52
+
53
+
54
+ int ValueTypeLessRef(ValueType* lt, ValueType* rt) {
55
+ assert(lt);
56
+ assert(rt);
57
+ return lt->value < rt->value;
58
+ }
59
+
60
+
61
+ size_t ValueTypeIdentifyRef(ValueType* self) {
62
+ assert(self);
63
+ return (size_t)self->value;
64
+ }
65
+
66
+
67
+ #undef element
68
+ #define element(x) ValueType##x
69
+
70
+
71
+ #undef Type
72
+ #define Type ValueTypeVector
73
+ #undef TypeIt
74
+ #define TypeIt ValueTypeVectorIt
75
+ #undef type
76
+ #define type(x) ValueTypeVector##x
77
+ #undef it
78
+ #define it(x) ValueTypeVectorIt##x
79
+
80
+
81
+ static void type(Test)() {
82
+ ValueType e1, e2;
83
+ Type c1, c2;
84
+ TypeIt it;
85
+
86
+ type(Ctor)(&c1, 3);
87
+ type(Copy)(&c2, &c1);
88
+
89
+ type(Resize)(&c1, 5);
90
+ type(Size)(&c1);
91
+ type(Equal)(&c1, &c2);
92
+ type(Resize)(&c1, 3);
93
+ type(Size)(&c1);
94
+ type(Equal)(&c1, &c2);
95
+
96
+ type(Within)(&c1, 0);
97
+ type(Within)(&c1, 10);
98
+
99
+ element(CtorEx)(&e1, -1);
100
+ element(CtorEx)(&e2, +1);
101
+ type(Set)(&c1, 2, e1);
102
+ type(Set)(&c1, 0, e2);
103
+ element(Dtor)(e1);
104
+ element(Dtor)(e2);
105
+
106
+ it(Ctor)(&it, &c1);
107
+ while(it(Move)(&it)) {
108
+ ValueType e = it(Get)(&it);
109
+ element(Dtor)(e);
110
+ }
111
+
112
+ it(CtorEx)(&it, &c2, 0);
113
+ while(it(Move)(&it)) {
114
+ ValueType e = it(Get)(&it);
115
+ element(Dtor)(e);
116
+ }
117
+
118
+ type(Sort)(&c1);
119
+ type(Sort)(&c2);
120
+
121
+ type(Identify)(&c1);
122
+ type(Identify)(&c2);
123
+
124
+ type(Dtor)(&c1);
125
+ type(Dtor)(&c2);
126
+ }
127
+
128
+
129
+ #undef Type
130
+ #define Type ValueTypeList
131
+ #undef TypeIt
132
+ #define TypeIt ValueTypeListIt
133
+ #undef type
134
+ #define type(x) ValueTypeList##x
135
+ #undef it
136
+ #define it(x) ValueTypeListIt##x
137
+
138
+
139
+ static void type(Test)() {
140
+ ValueType e1, e2, e3;
141
+ Type c1, c2;
142
+ TypeIt it;
143
+
144
+ type(Ctor)(&c1);
145
+ type(Copy)(&c2, &c1);
146
+
147
+ type(Equal)(&c1, &c2);
148
+ type(Empty)(&c1);
149
+
150
+ it(Ctor)(&it, &c1);
151
+ while(it(Move)(&it)) {
152
+ ValueType e = it(Get)(&it);
153
+ element(Dtor)(e);
154
+ }
155
+
156
+ element(CtorEx)(&e1, -1);
157
+ element(CtorEx)(&e2, +1);
158
+
159
+ type(Push)(&c1, e1);
160
+ type(Push)(&c2, e2);
161
+ type(Contains)(&c1, e1);
162
+ type(Contains)(&c2, e1);
163
+ type(Push)(&c1, e2);
164
+ type(Push)(&c2, e1);
165
+ type(Empty)(&c1);
166
+
167
+ element(Dtor)(e1);
168
+ element(Dtor)(e2);
169
+
170
+ e1 = type(Peek)(&c1);
171
+ e2 = type(Peek)(&c2);
172
+ element(Dtor)(e1);
173
+ element(Dtor)(e2);
174
+
175
+ it(Ctor)(&it, &c1);
176
+ while(it(Move)(&it)) {
177
+ ValueType e = it(Get)(&it);
178
+ element(Dtor)(e);
179
+ }
180
+
181
+ type(Identify)(&c1);
182
+ type(Identify)(&c2);
183
+
184
+ e1 = type(Pop)(&c1);
185
+ e2 = type(Pop)(&c2);
186
+ element(Dtor)(e1);
187
+ element(Dtor)(e2);
188
+
189
+ type(Purge)(&c1);
190
+ type(Purge)(&c2);
191
+
192
+ element(CtorEx)(&e1, 3);
193
+ element(CtorEx)(&e2, -3);
194
+ element(Copy)(e3, e2);
195
+ type(Push)(&c1, e1);
196
+ type(Push)(&c1, e2);
197
+ type(Push)(&c1, e1);
198
+ type(Push)(&c2, e2);
199
+ type(Push)(&c2, e2);
200
+ type(Push)(&c2, e2);
201
+ type(Replace)(&c2, e3);
202
+ type(ReplaceAll)(&c2, e3);
203
+ type(Remove)(&c1, e2);
204
+ type(Remove)(&c1, e1);
205
+ type(Remove)(&c2, e1);
206
+ type(RemoveAll)(&c2, e2);
207
+ element(Dtor)(e1);
208
+ element(Dtor)(e2);
209
+ element(Dtor)(e3);
210
+
211
+ type(Dtor)(&c1);
212
+ type(Dtor)(&c2);
213
+ }
214
+
215
+
216
+ #undef Type
217
+ #define Type ValueTypeQueue
218
+ #undef TypeIt
219
+ #define TypeIt ValueTypeQueueIt
220
+ #undef type
221
+ #define type(x) ValueTypeQueue##x
222
+ #undef it
223
+ #define it(x) ValueTypeQueueIt##x
224
+
225
+
226
+ /*
227
+ * Queue is a non-strict superset of List
228
+ * so the test case for the latter can be reused as-is
229
+ */
230
+ static void type(Test)() {
231
+ ValueType e1, e2, e3;
232
+ Type c1, c2;
233
+ TypeIt it;
234
+
235
+ type(Ctor)(&c1);
236
+ type(Copy)(&c2, &c1);
237
+
238
+ type(Equal)(&c1, &c2);
239
+ type(Empty)(&c1);
240
+
241
+ it(Ctor)(&it, &c1);
242
+ while(it(Move)(&it)) {
243
+ ValueType e = it(Get)(&it);
244
+ element(Dtor)(e);
245
+ }
246
+
247
+ element(CtorEx)(&e1, -1);
248
+ element(CtorEx)(&e2, +1);
249
+
250
+ type(Push)(&c1, e1);
251
+ type(Push)(&c2, e2);
252
+ type(Contains)(&c1, e1);
253
+ type(Contains)(&c2, e1);
254
+ type(Push)(&c1, e2);
255
+ type(Push)(&c2, e1);
256
+ type(Empty)(&c1);
257
+
258
+ element(Dtor)(e1);
259
+ element(Dtor)(e2);
260
+
261
+ e1 = type(Peek)(&c1);
262
+ e2 = type(Peek)(&c2);
263
+ element(Dtor)(e1);
264
+ element(Dtor)(e2);
265
+
266
+ it(Ctor)(&it, &c1);
267
+ while(it(Move)(&it)) {
268
+ ValueType e = it(Get)(&it);
269
+ element(Dtor)(e);
270
+ }
271
+
272
+ type(Identify)(&c1);
273
+ type(Identify)(&c2);
274
+
275
+ e1 = type(Pop)(&c1);
276
+ e2 = type(Pop)(&c2);
277
+ element(Dtor)(e1);
278
+ element(Dtor)(e2);
279
+
280
+ type(Purge)(&c1);
281
+ type(Purge)(&c2);
282
+
283
+ element(CtorEx)(&e1, 3);
284
+ element(CtorEx)(&e2, -3);
285
+ element(Copy)(e3, e2);
286
+ type(Push)(&c1, e1);
287
+ type(Push)(&c1, e2);
288
+ type(Push)(&c1, e1);
289
+ type(Push)(&c2, e2);
290
+ type(Push)(&c2, e2);
291
+ type(Push)(&c2, e2);
292
+ type(Replace)(&c2, e3);
293
+ type(ReplaceAll)(&c2, e3);
294
+ type(Remove)(&c1, e2);
295
+ type(Remove)(&c1, e1);
296
+ type(Remove)(&c2, e1);
297
+ type(RemoveAll)(&c2, e2);
298
+ element(Dtor)(e1);
299
+ element(Dtor)(e2);
300
+ element(Dtor)(e3);
301
+
302
+ type(Dtor)(&c1);
303
+ type(Dtor)(&c2);
304
+ }
305
+
306
+
307
+ #undef Type
308
+ #define Type ValueTypeSet
309
+ #undef TypeIt
310
+ #define TypeIt ValueTypeSetIt
311
+ #undef type
312
+ #define type(x) ValueTypeSet##x
313
+ #undef it
314
+ #define it(x) ValueTypeSetIt##x
315
+
316
+
317
+ static void type(Test)() {
318
+ ValueType e1, e2, e3;
319
+ Type c1, c2, cc1, cc2;
320
+ TypeIt it;
321
+
322
+ type(Ctor)(&c1);
323
+ type(Copy)(&c2, &c1);
324
+
325
+ it(Ctor)(&it, &c1);
326
+ while(it(Move)(&it)) {
327
+ ValueType e = it(Get)(&it);
328
+ element(Dtor)(e);
329
+ }
330
+
331
+ type(Equal)(&c1, &c2);
332
+ type(Empty)(&c1);
333
+ type(Size)(&c1);
334
+
335
+ element(CtorEx)(&e1, -1);
336
+ element(CtorEx)(&e2, +1);
337
+ element(CtorEx)(&e3, 0);
338
+
339
+ type(Put)(&c1, e1);
340
+ type(Put)(&c2, e1);
341
+ type(Equal)(&c1, &c2);
342
+ type(Put)(&c1, e2);
343
+ type(Put)(&c2, e3);
344
+ type(Equal)(&c1, &c2);
345
+ type(Contains)(&c1, e1);
346
+ type(Contains)(&c2, e2);
347
+ {
348
+ ValueType e = type(Get)(&c2, e3);
349
+ element(Dtor)(e);
350
+ }
351
+ type(Replace)(&c1, e2);
352
+
353
+ type(Put)(&c2, e1);
354
+ type(Put)(&c2, e2);
355
+ type(Put)(&c2, e3);
356
+
357
+ element(Dtor)(e1);
358
+ element(Dtor)(e2);
359
+ element(Dtor)(e3);
360
+
361
+ {
362
+ int i;
363
+ ValueType e;
364
+ for(i = 0; i < 100; ++i) {
365
+ element(CtorEx)(&e, i);
366
+ type(Put)(&c1, e);
367
+ element(Dtor)(e);
368
+ }
369
+ for(i = 0; i < 100; i += 2) {
370
+ element(CtorEx)(&e, i);
371
+ type(Remove)(&c1, e);
372
+ element(Dtor)(e);
373
+ }
374
+ it(Ctor)(&it, &c1);
375
+ while(it(Move)(&it)) {
376
+ ValueType e = it(Get)(&it);
377
+ element(Dtor)(e);
378
+ }
379
+ }
380
+
381
+ {
382
+ type(Copy)(&cc1, &c1);
383
+ type(Copy)(&cc2, &c2);
384
+ type(Retain)(&cc1, &cc2);
385
+ type(Dtor)(&cc1);
386
+ type(Dtor)(&cc2);
387
+ }
388
+
389
+ {
390
+ type(Copy)(&cc1, &c1);
391
+ type(Copy)(&cc2, &c2);
392
+ type(Retain)(&cc2, &cc1);
393
+ type(Dtor)(&cc1);
394
+ type(Dtor)(&cc2);
395
+ }
396
+
397
+ {
398
+ type(Copy)(&cc1, &c1);
399
+ type(Copy)(&cc2, &c2);
400
+ type(Include)(&cc1, &cc2);
401
+ type(Dtor)(&cc1);
402
+ type(Dtor)(&cc2);
403
+ }
404
+
405
+ {
406
+ type(Copy)(&cc1, &c1);
407
+ type(Copy)(&cc2, &c2);
408
+ type(Include)(&cc2, &cc1);
409
+ type(Dtor)(&cc1);
410
+ type(Dtor)(&cc2);
411
+ }
412
+
413
+ {
414
+ type(Copy)(&cc1, &c1);
415
+ type(Copy)(&cc2, &c2);
416
+ type(Exclude)(&cc1, &cc2);
417
+ type(Dtor)(&cc1);
418
+ type(Dtor)(&cc2);
419
+ }
420
+
421
+ {
422
+ type(Copy)(&cc1, &c1);
423
+ type(Copy)(&cc2, &c2);
424
+ type(Exclude)(&cc2, &cc1);
425
+ type(Dtor)(&cc1);
426
+ type(Dtor)(&cc2);
427
+ }
428
+
429
+ {
430
+ type(Copy)(&cc1, &c1);
431
+ type(Copy)(&cc2, &c2);
432
+ type(Invert)(&cc1, &cc2);
433
+ type(Dtor)(&cc1);
434
+ type(Dtor)(&cc2);
435
+ }
436
+
437
+ {
438
+ type(Copy)(&cc1, &c1);
439
+ type(Copy)(&cc2, &c2);
440
+ type(Invert)(&cc2, &cc1);
441
+ type(Dtor)(&cc1);
442
+ type(Dtor)(&cc2);
443
+ }
444
+
445
+ type(Identify)(&c1);
446
+ type(Identify)(&c2);
447
+
448
+ type(Purge)(&c1);
449
+ type(Dtor)(&c1);
450
+ type(Dtor)(&c2);
451
+ }
452
+
453
+
454
+ #undef Type
455
+ #define Type ValueTypeMap
456
+ #undef TypeIt
457
+ #define TypeIt ValueTypeMapIt
458
+ #undef type
459
+ #define type(x) ValueTypeMap##x
460
+ #undef it
461
+ #define it(x) ValueTypeMapIt##x
462
+
463
+
464
+ static void type(Test)() {
465
+ ValueType e1, e2, e3;
466
+ Type c1, c2;
467
+ TypeIt it;
468
+
469
+ element(CtorEx)(&e1, -1);
470
+ element(CtorEx)(&e2, +1);
471
+ element(CtorEx)(&e3, 0);
472
+
473
+ type(Ctor)(&c1);
474
+ type(Put)(&c1, e1, e3);
475
+ type(Put)(&c1, e2, e3);
476
+ type(Copy)(&c2, &c1);
477
+
478
+ type(Put)(&c1, e1, e2);
479
+ type(Put)(&c2, e2, e1);
480
+
481
+ {
482
+ int i;
483
+ ValueType e;
484
+ for(i = 0; i < 100; ++i) {
485
+ element(CtorEx)(&e, i);
486
+ type(Put)(&c1, e, e);
487
+ element(Dtor)(e);
488
+ }
489
+ for(i = 0; i < 100; i += 2) {
490
+ element(CtorEx)(&e, i);
491
+ type(Remove)(&c1, e);
492
+ element(Dtor)(e);
493
+ }
494
+ for(i = 1; i < 10; ++i) {
495
+ ValueType k;
496
+ element(CtorEx)(&k, i);
497
+ element(CtorEx)(&e, -i);
498
+ type(Replace)(&c1, k, e);
499
+ element(Dtor)(k);
500
+ element(Dtor)(e);
501
+ }
502
+ }
503
+
504
+ it(Ctor)(&it, &c1);
505
+ while(it(Move)(&it)) {
506
+ ValueType k = it(GetKey)(&it), e = it(GetElement)(&it);
507
+ element(Dtor)(k);
508
+ element(Dtor)(e);
509
+ }
510
+
511
+ element(Dtor)(e1);
512
+ element(Dtor)(e2);
513
+ element(Dtor)(e3);
514
+
515
+ type(Equal)(&c1, &c2);
516
+ type(Empty)(&c1);
517
+ type(Size)(&c1);
518
+
519
+ type(Identify)(&c1);
520
+ type(Identify)(&c2);
521
+
522
+ type(Purge)(&c1);
523
+ type(Dtor)(&c1);
524
+ type(Dtor)(&c2);
525
+ }
526
+
527
+
528
+ #undef Type
529
+ #define Type IntSet
530
+ #undef TypeIt
531
+ #define TypeIt IntSetIt
532
+ #undef type
533
+ #define type(x) IntSet##x
534
+ #undef it
535
+ #define it(x) IntSetIt##x
536
+
537
+
538
+ /* {1,2,3} & {2,3,4} == {2,3} */
539
+ static void type(TestAnd)() {
540
+ Type r, c1, c2, cc1, cc2;
541
+
542
+ type(Ctor)(&r);
543
+ type(Ctor)(&c1);
544
+ type(Ctor)(&c2);
545
+
546
+ assert(type(Empty)(&r));
547
+ assert(type(Empty)(&c1));
548
+ assert(type(Empty)(&c2));
549
+
550
+ type(Put)(&c1, 1); type(Put)(&c1, 3);
551
+ type(Put)(&c1, 2);
552
+ type(Put)(&c1, 3); type(Put)(&c1, 1);
553
+
554
+ assert(type(Size)(&c1) == 3);
555
+
556
+ type(Copy)(&cc1, &c1);
557
+
558
+ type(Put)(&c2, 2);
559
+ type(Put)(&c2, 3);
560
+ type(Put)(&c2, 4);
561
+
562
+ assert(type(Size)(&c2) == 3);
563
+
564
+ type(Copy)(&cc2, &c2);
565
+
566
+ assert(!type(Equal)(&c1, &c2));
567
+ assert(!type(Equal)(&c2, &c1));
568
+
569
+ type(Retain)(&c1, &c2);
570
+ type(Retain)(&cc2, &cc1);
571
+
572
+ assert(type(Size)(&c1) == 2);
573
+ assert(type(Size)(&cc2) == 2);
574
+
575
+ type(Put)(&r, 3);
576
+ type(Put)(&r, 2);
577
+
578
+ assert(type(Size)(&r) == 2);
579
+
580
+ assert(!type(Empty)(&r));
581
+ assert(!type(Empty)(&c1));
582
+ assert(!type(Empty)(&c2));
583
+
584
+ assert(type(Equal)(&c1, &r));
585
+ assert(type(Equal)(&r, &c1));
586
+
587
+ assert(type(Equal)(&cc2, &c1));
588
+ assert(type(Equal)(&c1, &cc2));
589
+
590
+ type(Dtor)(&r);
591
+ type(Dtor)(&c1);
592
+ type(Dtor)(&c2);
593
+ type(Dtor)(&cc1);
594
+ type(Dtor)(&cc2);
595
+ }
596
+
597
+
598
+ /* {1,2,3} | {2,3,4} == {1,2,3,4} */
599
+ static void type(TestOr)() {
600
+ Type r, c1, c2, cc1, cc2;
601
+
602
+ type(Ctor)(&r);
603
+ type(Ctor)(&c1);
604
+ type(Ctor)(&c2);
605
+
606
+ assert(type(Empty)(&r));
607
+ assert(type(Empty)(&c1));
608
+ assert(type(Empty)(&c2));
609
+
610
+ type(Put)(&c1, 1); type(Put)(&c1, 3);
611
+ type(Put)(&c1, 2);
612
+ type(Put)(&c1, 3); type(Put)(&c1, 1);
613
+
614
+ assert(type(Size)(&c1) == 3);
615
+
616
+ type(Copy)(&cc1, &c1);
617
+
618
+ type(Put)(&c2, 2);
619
+ type(Put)(&c2, 3);
620
+ type(Put)(&c2, 4);
621
+
622
+ assert(type(Size)(&c2) == 3);
623
+
624
+ type(Copy)(&cc2, &c2);
625
+
626
+ assert(!type(Equal)(&c1, &c2));
627
+ assert(!type(Equal)(&c2, &c1));
628
+
629
+ type(Include)(&c1, &c2);
630
+ type(Include)(&cc2, &cc1);
631
+
632
+ assert(type(Size)(&c1) == 4);
633
+ assert(type(Size)(&cc2) == 4);
634
+
635
+ type(Put)(&r, 3);
636
+ type(Put)(&r, 2);
637
+ type(Put)(&r, 1);
638
+ type(Put)(&r, 4);
639
+
640
+ assert(type(Size)(&r) == 4);
641
+
642
+ assert(!type(Empty)(&r));
643
+ assert(!type(Empty)(&c1));
644
+ assert(!type(Empty)(&c2));
645
+
646
+ assert(type(Equal)(&c1, &r));
647
+ assert(type(Equal)(&r, &c1));
648
+
649
+ assert(type(Equal)(&cc2, &c1));
650
+ assert(type(Equal)(&c1, &cc2));
651
+
652
+ type(Dtor)(&r);
653
+ type(Dtor)(&c1);
654
+ type(Dtor)(&c2);
655
+ type(Dtor)(&cc1);
656
+ type(Dtor)(&cc2);
657
+ }
658
+
659
+
660
+ /* {1,2,3} ^ {2,3,4} == {1,4} */
661
+ static void type(TestXor)() {
662
+ Type r, c1, c2, cc1, cc2;
663
+
664
+ type(Ctor)(&r);
665
+ type(Ctor)(&c1);
666
+ type(Ctor)(&c2);
667
+
668
+ assert(type(Empty)(&r));
669
+ assert(type(Empty)(&c1));
670
+ assert(type(Empty)(&c2));
671
+
672
+ type(Put)(&c1, 1); type(Put)(&c1, 3);
673
+ type(Put)(&c1, 2);
674
+ type(Put)(&c1, 3); type(Put)(&c1, 1);
675
+
676
+ assert(type(Size)(&c1) == 3);
677
+
678
+ type(Copy)(&cc1, &c1);
679
+
680
+ type(Put)(&c2, 2);
681
+ type(Put)(&c2, 3);
682
+ type(Put)(&c2, 4);
683
+
684
+ assert(type(Size)(&c2) == 3);
685
+
686
+ type(Copy)(&cc2, &c2);
687
+
688
+ assert(!type(Equal)(&c1, &c2));
689
+ assert(!type(Equal)(&c2, &c1));
690
+
691
+ type(Invert)(&c1, &c2);
692
+ type(Invert)(&cc2, &cc1);
693
+
694
+ assert(type(Size)(&c1) == 2);
695
+ assert(type(Size)(&cc2) == 2);
696
+
697
+ type(Put)(&r, 4);
698
+ type(Put)(&r, 1);
699
+
700
+ assert(type(Size)(&r) == 2);
701
+
702
+ assert(!type(Empty)(&r));
703
+ assert(!type(Empty)(&c1));
704
+ assert(!type(Empty)(&c2));
705
+
706
+ assert(type(Equal)(&c1, &r));
707
+ assert(type(Equal)(&r, &c1));
708
+
709
+ assert(type(Equal)(&cc2, &c1));
710
+ assert(type(Equal)(&c1, &cc2));
711
+
712
+ type(Dtor)(&r);
713
+ type(Dtor)(&c1);
714
+ type(Dtor)(&c2);
715
+ type(Dtor)(&cc1);
716
+ type(Dtor)(&cc2);
717
+ }
718
+
719
+
720
+ /* {1,2,3} - {2,3,4} == {1} */
721
+ static void type(TestNot1)() {
722
+ Type r, c1, c2, cc1, cc2;
723
+
724
+ type(Ctor)(&r);
725
+ type(Ctor)(&c1);
726
+ type(Ctor)(&c2);
727
+
728
+ assert(type(Empty)(&r));
729
+ assert(type(Empty)(&c1));
730
+ assert(type(Empty)(&c2));
731
+
732
+ type(Put)(&c1, 1); type(Put)(&c1, 3);
733
+ type(Put)(&c1, 2);
734
+ type(Put)(&c1, 3); type(Put)(&c1, 1);
735
+
736
+ assert(type(Size)(&c1) == 3);
737
+
738
+ type(Copy)(&cc1, &c1);
739
+
740
+ type(Put)(&c2, 2);
741
+ type(Put)(&c2, 3);
742
+ type(Put)(&c2, 4);
743
+
744
+ assert(type(Size)(&c2) == 3);
745
+
746
+ type(Copy)(&cc2, &c2);
747
+
748
+ assert(!type(Equal)(&c1, &c2));
749
+ assert(!type(Equal)(&c2, &c1));
750
+
751
+ type(Exclude)(&c1, &c2);
752
+ type(Exclude)(&cc2, &cc1);
753
+
754
+ assert(type(Size)(&c1) == 1);
755
+ assert(type(Size)(&cc2) == 1);
756
+
757
+ type(Put)(&r, 1);
758
+
759
+ assert(type(Size)(&r) == 1);
760
+
761
+ assert(!type(Empty)(&r));
762
+ assert(!type(Empty)(&c1));
763
+ assert(!type(Empty)(&c2));
764
+
765
+ assert(type(Equal)(&c1, &r));
766
+ assert(type(Equal)(&r, &c1));
767
+
768
+ assert(!type(Equal)(&cc2, &c1));
769
+ assert(!type(Equal)(&c1, &cc2));
770
+
771
+ type(Dtor)(&r);
772
+ type(Dtor)(&c1);
773
+ type(Dtor)(&c2);
774
+ type(Dtor)(&cc1);
775
+ type(Dtor)(&cc2);
776
+ }
777
+
778
+
779
+ /* {1,2,3} - {1,2,3,4} == {} */
780
+ static void type(TestNot2)() {
781
+ Type r, c1, c2;
782
+
783
+ type(Ctor)(&r);
784
+ type(Ctor)(&c1);
785
+ type(Ctor)(&c2);
786
+
787
+ assert(type(Empty)(&r));
788
+ assert(type(Empty)(&c1));
789
+ assert(type(Empty)(&c2));
790
+
791
+ type(Put)(&c1, 1); type(Put)(&c1, 3);
792
+ type(Put)(&c1, 2);
793
+ type(Put)(&c1, 3); type(Put)(&c1, 1);
794
+
795
+ assert(type(Size)(&c1) == 3);
796
+
797
+ type(Put)(&c2, 1);
798
+ type(Put)(&c2, 2);
799
+ type(Put)(&c2, 3);
800
+ type(Put)(&c2, 4);
801
+
802
+ assert(type(Size)(&c2) == 4);
803
+
804
+ assert(!type(Equal)(&c1, &c2));
805
+ assert(!type(Equal)(&c2, &c1));
806
+
807
+ type(Exclude)(&c1, &c2);
808
+
809
+ assert(type(Size)(&c1) == 0);
810
+
811
+ assert(type(Size)(&r) == 0);
812
+
813
+ assert(type(Empty)(&r));
814
+ assert(type(Empty)(&c1));
815
+ assert(!type(Empty)(&c2));
816
+
817
+ assert(type(Equal)(&c1, &r));
818
+ assert(type(Equal)(&r, &c1));
819
+
820
+ type(Dtor)(&r);
821
+ type(Dtor)(&c1);
822
+ type(Dtor)(&c2);
823
+ }
824
+
825
+
826
+ #undef Type
827
+ #define Type IntStrMap
828
+ #undef TypeIt
829
+ #define TypeIt IntStrMapIt
830
+ #undef type
831
+ #define type(x) IntStrMap##x
832
+ #undef it
833
+ #define it(x) IntStrMapIt##x
834
+
835
+
836
+ static const char* zero = "zero";
837
+ static const char* one = "one";
838
+ static const char* two = "two";
839
+
840
+
841
+ static void type(Test)() {
842
+ Type c1, c2;
843
+ TypeIt it;
844
+ int i;
845
+
846
+ type(Ctor)(&c1);
847
+ type(Ctor)(&c2);
848
+
849
+ assert(type(Empty)(&c1));
850
+ assert(type(Empty)(&c2));
851
+ assert(type(Equal)(&c1, &c2));
852
+
853
+ assert(type(Put)(&c1, 0, zero));
854
+ assert(type(Put)(&c1, 1, one));
855
+ assert(type(Put)(&c1, 2, two));
856
+ assert(!type(Put)(&c1, 2, two));
857
+
858
+ assert(type(Put)(&c2, 2, two));
859
+ assert(type(Put)(&c2, 0, zero));
860
+ assert(type(Put)(&c2, 1, one));
861
+ assert(!type(Put)(&c2, 0, zero));
862
+
863
+ assert(!type(Empty)(&c1));
864
+ assert(!type(Empty)(&c2));
865
+ assert(type(Size)(&c1) == type(Size)(&c2));
866
+ assert(type(Equal)(&c1, &c2));
867
+
868
+ assert(type(ContainsKey)(&c1, 0));
869
+ assert(type(Remove)(&c1, 0));
870
+ assert(!type(Remove)(&c1, 0));
871
+ assert(!type(ContainsKey)(&c1, 0));
872
+ assert(type(ContainsKey)(&c2, 2));
873
+ assert(type(Remove)(&c2, 2));
874
+ assert(!type(ContainsKey)(&c2, 2));
875
+ assert(type(Size)(&c1) == type(Size)(&c2));
876
+ assert(!type(Equal)(&c1, &c2));
877
+
878
+ type(Purge)(&c1);
879
+
880
+ assert(type(Put)(&c1, 0, zero));
881
+ assert(type(Put)(&c1, 1, one));
882
+ assert(type(Put)(&c1, 2, two));
883
+
884
+ assert(type(Replace)(&c1, 0, two));
885
+ assert(type(Replace)(&c1, 2, zero));
886
+
887
+ assert(type(Get)(&c1, 0) == two);
888
+ assert(type(Get)(&c1, 2) == zero);
889
+ assert(type(Get)(&c1, 1) == one);
890
+
891
+ i = 0;
892
+ it(Ctor)(&it, &c1);
893
+ while(it(Move)(&it)) {
894
+ int k;
895
+ const char* e;
896
+ k = it(GetKey)(&it);
897
+ e = it(Get)(&it);
898
+ ++i;
899
+ }
900
+ assert(i == 3);
901
+
902
+ type(Purge)(&c2);
903
+ type(Dtor)(&c1);
904
+ type(Dtor)(&c2);
905
+ }
906
+
907
+
908
+ int main(int argc, char** argv) {
909
+ ValueTypeVectorTest();
910
+ ValueTypeListTest();
911
+ ValueTypeQueueTest();
912
+ ValueTypeSetTest();
913
+ ValueTypeMapTest();
914
+ IntSetTestAnd();
915
+ IntSetTestOr();
916
+ IntSetTestXor();
917
+ IntSetTestNot1();
918
+ IntSetTestNot2();
919
+ IntStrMapTest();
920
+ return 0;
921
+ }