autoc 0.8 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README +15 -4
- data/doc/AutoC.html +245 -0
- data/doc/AutoC/Code.html +520 -0
- data/doc/AutoC/Collection.html +923 -0
- data/doc/AutoC/HashMap.html +1161 -0
- data/doc/AutoC/HashSet.html +1122 -0
- data/doc/AutoC/List.html +1002 -0
- data/doc/AutoC/Module.html +951 -0
- data/doc/AutoC/Module/File.html +412 -0
- data/doc/AutoC/Module/Header.html +432 -0
- data/doc/AutoC/Module/Source.html +704 -0
- data/doc/AutoC/Priority.html +138 -0
- data/doc/AutoC/Queue.html +1167 -0
- data/doc/AutoC/Type.html +1152 -0
- data/doc/AutoC/UserDefinedType.html +655 -0
- data/doc/AutoC/Vector.html +856 -0
- data/doc/_index.html +299 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +112 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +112 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +605 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/autoc.rb +35 -12
- data/lib/autoc/{code_builder.rb → code.rb} +230 -247
- data/lib/autoc/collection.rb +137 -0
- data/lib/autoc/collection/hash_map.rb +388 -0
- data/lib/autoc/collection/hash_set.rb +433 -0
- data/lib/autoc/collection/list.rb +410 -0
- data/lib/autoc/collection/queue.rb +514 -0
- data/lib/autoc/collection/vector.rb +295 -0
- data/lib/autoc/type.rb +198 -0
- data/test/test.c +921 -396
- data/test/test.h +41 -0
- data/test/test.rb +21 -26
- data/test/test_auto.c +2630 -3961
- data/test/test_auto.h +449 -560
- metadata +50 -17
- data/lib/autoc/data_struct_builder.rb +0 -1794
- data/lib/autoc/type_builder.rb +0 -24
- data/manual/manual.pdf +0 -0
data/test/test.c
CHANGED
@@ -1,396 +1,921 @@
|
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
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
|
+
}
|