autoc 1.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGES.md +3 -0
- data/README.md +149 -0
- data/cmake/AutoC.cmake +39 -0
- data/lib/autoc/allocators.rb +51 -0
- data/lib/autoc/association.rb +126 -0
- data/lib/autoc/box.rb +311 -0
- data/lib/autoc/cmake.rb +54 -0
- data/lib/autoc/collection.rb +83 -110
- data/lib/autoc/composite.rb +333 -0
- data/lib/autoc/cstring.rb +263 -0
- data/lib/autoc/function.rb +247 -0
- data/lib/autoc/hash_map.rb +328 -0
- data/lib/autoc/hash_set.rb +339 -0
- data/lib/autoc/hashers.rb +102 -0
- data/lib/autoc/list.rb +444 -0
- data/lib/autoc/module.rb +434 -0
- data/lib/autoc/openmp.rb +15 -0
- data/lib/autoc/primitive.rb +27 -0
- data/lib/autoc/ranges.rb +707 -0
- data/lib/autoc/record.rb +247 -0
- data/lib/autoc/scaffold/docs.rb +117 -0
- data/lib/autoc/scaffold/generic_value.rb +86 -0
- data/lib/autoc/scaffold/project.rb +75 -0
- data/lib/autoc/scaffold/test_cstring.rb +113 -0
- data/lib/autoc/scaffold/test_cstring_hash_set.rb +35 -0
- data/lib/autoc/scaffold/test_int_box.rb +22 -0
- data/lib/autoc/scaffold/test_int_hash_set.rb +448 -0
- data/lib/autoc/scaffold/test_int_list.rb +106 -0
- data/lib/autoc/scaffold/test_int_vector.rb +83 -0
- data/lib/autoc/scaffold/test_v2v_hash_map.rb +83 -0
- data/lib/autoc/scaffold/test_value_hash_set.rb +60 -0
- data/lib/autoc/scaffold/test_value_vector.rb +146 -0
- data/{test/test.rb → lib/autoc/scaffold/tests.rb} +179 -158
- data/lib/autoc/scaffold.rb +12 -0
- data/lib/autoc/sequential.rb +99 -0
- data/lib/autoc/set.rb +331 -0
- data/lib/autoc/std.rb +149 -0
- data/lib/autoc/type.rb +93 -531
- data/lib/autoc/vector.rb +290 -0
- data/lib/autoc.rb +4 -35
- metadata +55 -85
- data/.yardopts +0 -4
- data/CHANGES +0 -23
- data/README +0 -28
- data/doc/AutoC/Code.html +0 -523
- data/doc/AutoC/Collection.html +0 -1214
- data/doc/AutoC/HashMap.html +0 -1441
- data/doc/AutoC/HashSet.html +0 -916
- data/doc/AutoC/Iterators/Bidirectional.html +0 -204
- data/doc/AutoC/Iterators/Unidirectional.html +0 -200
- data/doc/AutoC/Iterators.html +0 -126
- data/doc/AutoC/List.html +0 -1039
- data/doc/AutoC/Maps.html +0 -290
- data/doc/AutoC/Module/File.html +0 -415
- data/doc/AutoC/Module/Header.html +0 -437
- data/doc/AutoC/Module/Source.html +0 -707
- data/doc/AutoC/Module.html +0 -948
- data/doc/AutoC/Priority.html +0 -138
- data/doc/AutoC/Queue.html +0 -1172
- data/doc/AutoC/Reference.html +0 -735
- data/doc/AutoC/Sets.html +0 -520
- data/doc/AutoC/String.html +0 -1394
- data/doc/AutoC/TreeMap.html +0 -1565
- data/doc/AutoC/TreeSet.html +0 -1447
- data/doc/AutoC/Type.html +0 -2148
- data/doc/AutoC/UserDefinedType.html +0 -1047
- data/doc/AutoC/Vector.html +0 -987
- data/doc/AutoC.html +0 -331
- data/doc/_index.html +0 -388
- data/doc/class_list.html +0 -51
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -58
- data/doc/css/style.css +0 -481
- data/doc/file.CHANGES.html +0 -117
- data/doc/file.README.html +0 -116
- data/doc/file_list.html +0 -61
- data/doc/frames.html +0 -17
- data/doc/index.html +0 -116
- data/doc/js/app.js +0 -243
- data/doc/js/full_list.js +0 -216
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -1307
- data/doc/top-level-namespace.html +0 -112
- data/lib/autoc/code.rb +0 -237
- data/lib/autoc/collection/hash_map.rb +0 -385
- data/lib/autoc/collection/hash_set.rb +0 -337
- data/lib/autoc/collection/iterator.rb +0 -39
- data/lib/autoc/collection/list.rb +0 -429
- data/lib/autoc/collection/map.rb +0 -41
- data/lib/autoc/collection/queue.rb +0 -517
- data/lib/autoc/collection/set.rb +0 -134
- data/lib/autoc/collection/tree_map.rb +0 -464
- data/lib/autoc/collection/tree_set.rb +0 -611
- data/lib/autoc/collection/vector.rb +0 -336
- data/lib/autoc/string.rb +0 -492
- data/test/test_auto.c +0 -7141
- data/test/test_auto.h +0 -753
- data/test/test_char_string.rb +0 -270
- data/test/test_int_list.rb +0 -35
- data/test/test_int_tree_set.rb +0 -111
- data/test/test_int_vector.rb +0 -34
- data/test/test_value_hash_map.rb +0 -162
- data/test/test_value_hash_set.rb +0 -173
- data/test/test_value_list.rb +0 -193
- data/test/test_value_queue.rb +0 -275
- data/test/test_value_tree_map.rb +0 -176
- data/test/test_value_tree_set.rb +0 -173
- data/test/test_value_vector.rb +0 -155
- data/test/value.rb +0 -80
data/test/test_char_string.rb
DELETED
@@ -1,270 +0,0 @@
|
|
1
|
-
type_test(AutoC::String, :CharString) do
|
2
|
-
|
3
|
-
setup %~#{type} t;~
|
4
|
-
cleanup %~#{dtor}(&t);~
|
5
|
-
|
6
|
-
test :create, %~
|
7
|
-
#{ctor}(&t, "XYZ");
|
8
|
-
~
|
9
|
-
|
10
|
-
test :createWithNULL, %~
|
11
|
-
#{ctor}(&t, NULL);
|
12
|
-
TEST_TRUE( #{empty}(&t) );
|
13
|
-
~
|
14
|
-
|
15
|
-
test :createWithEmptyChars, %~
|
16
|
-
#{ctor}(&t, "");
|
17
|
-
TEST_TRUE( #{empty}(&t) );
|
18
|
-
~
|
19
|
-
|
20
|
-
test :hash, %~
|
21
|
-
#{ctor}(&t, "XYZ");
|
22
|
-
#{identify}(&t);
|
23
|
-
~
|
24
|
-
|
25
|
-
test :within, %~
|
26
|
-
#{ctor}(&t, "XYZ");
|
27
|
-
TEST_FALSE( #{empty}(&t) );
|
28
|
-
TEST_TRUE( #{within}(&t, 0) );
|
29
|
-
TEST_TRUE( #{within}(&t, 2) );
|
30
|
-
TEST_FALSE( #{within}(&t, 3) );
|
31
|
-
~
|
32
|
-
|
33
|
-
test :withinNULLString, %~
|
34
|
-
#{ctor}(&t, NULL);
|
35
|
-
TEST_TRUE( #{empty}(&t) );
|
36
|
-
TEST_FALSE( #{within}(&t, 0) );
|
37
|
-
TEST_FALSE( #{within}(&t, 1) );
|
38
|
-
~
|
39
|
-
|
40
|
-
test :withinEmptyString, %~
|
41
|
-
#{ctor}(&t, "");
|
42
|
-
TEST_TRUE( #{empty}(&t) );
|
43
|
-
TEST_FALSE( #{within}(&t, 0) );
|
44
|
-
TEST_FALSE( #{within}(&t, 1) );
|
45
|
-
~
|
46
|
-
test :stringSize, %~
|
47
|
-
#{ctor}(&t, "XYZ");
|
48
|
-
TEST_EQUAL( #{size}(&t), 3 );
|
49
|
-
~
|
50
|
-
|
51
|
-
test :emptyStringSize, %~
|
52
|
-
#{ctor}(&t, "");
|
53
|
-
TEST_TRUE( #{empty}(&t) );
|
54
|
-
TEST_EQUAL( #{size}(&t), 0 );
|
55
|
-
~
|
56
|
-
|
57
|
-
test :NULLStringSize, %~
|
58
|
-
#{ctor}(&t, NULL);
|
59
|
-
TEST_TRUE( #{empty}(&t) );
|
60
|
-
TEST_EQUAL( #{size}(&t), 0 );
|
61
|
-
~
|
62
|
-
|
63
|
-
test :chars, %~
|
64
|
-
#{ctor}(&t, "XYZ");
|
65
|
-
TEST_EQUAL_CHARS( #{chars}(&t), "XYZ" );
|
66
|
-
TEST_NOT_EQUAL_CHARS( #{chars}(&t), "xyz" );
|
67
|
-
~
|
68
|
-
|
69
|
-
test :getChar, %~
|
70
|
-
#{ctor}(&t, "XYZ");
|
71
|
-
TEST_EQUAL( #{get}(&t, 2), 'Z' );
|
72
|
-
~
|
73
|
-
|
74
|
-
test :setChar, %~
|
75
|
-
#{ctor}(&t, "XYZ");
|
76
|
-
TEST_NOT_EQUAL( #{get}(&t, 0), 'x' );
|
77
|
-
#{set}(&t, 0, 'x');
|
78
|
-
TEST_EQUAL( #{get}(&t, 0), 'x' );
|
79
|
-
~
|
80
|
-
|
81
|
-
test :pushChars, %~
|
82
|
-
#{ctor}(&t, "X");
|
83
|
-
#{pushChars}(&t, "Y");
|
84
|
-
#{pushChars}(&t, "Z");
|
85
|
-
TEST_EQUAL_CHARS( #{chars}(&t), "XYZ" );
|
86
|
-
~
|
87
|
-
|
88
|
-
test :pushEmptyChars, %~
|
89
|
-
#{ctor}(&t, "XYZ");
|
90
|
-
#{pushChars}(&t, "");
|
91
|
-
TEST_EQUAL_CHARS( #{chars}(&t), "XYZ" );
|
92
|
-
~
|
93
|
-
|
94
|
-
test :pushCharsToNULL, %~
|
95
|
-
#{ctor}(&t, NULL);
|
96
|
-
#{pushChars}(&t, "XY");
|
97
|
-
#{pushChars}(&t, "Z");
|
98
|
-
TEST_EQUAL_CHARS( #{chars}(&t), "XYZ" );
|
99
|
-
~
|
100
|
-
|
101
|
-
test :pushCharsToEmpty, %~
|
102
|
-
#{ctor}(&t, "");
|
103
|
-
#{pushChars}(&t, "X");
|
104
|
-
#{pushChars}(&t, "YZ");
|
105
|
-
TEST_EQUAL_CHARS( #{chars}(&t), "XYZ" );
|
106
|
-
~
|
107
|
-
|
108
|
-
test :pushString, %~
|
109
|
-
#{type} s;
|
110
|
-
#{ctor}(&s, "YZ");
|
111
|
-
#{ctor}(&t, "X");
|
112
|
-
#{pushString}(&t, &s);
|
113
|
-
TEST_EQUAL_CHARS( #{chars}(&t), "XYZ" );
|
114
|
-
#{dtor}(&s);
|
115
|
-
~
|
116
|
-
|
117
|
-
test :pushChar, %~
|
118
|
-
#{ctor}(&t, "XY");
|
119
|
-
#{pushChar}(&t, 'Z');
|
120
|
-
TEST_EQUAL_CHARS( #{chars}(&t), "XYZ" );
|
121
|
-
~
|
122
|
-
|
123
|
-
test :pushInt, %~
|
124
|
-
#{ctor}(&t, "XYZ");
|
125
|
-
#{pushInt}(&t, -123);
|
126
|
-
TEST_EQUAL_CHARS( #{chars}(&t), "XYZ-123" );
|
127
|
-
~
|
128
|
-
|
129
|
-
test :pushFloat, %~
|
130
|
-
#{ctor}(&t, "XYZ");
|
131
|
-
#{pushFloat}(&t, -1.23);
|
132
|
-
~
|
133
|
-
|
134
|
-
test :pushPtr, %~
|
135
|
-
#{ctor}(&t, "XYZ");
|
136
|
-
#{pushPtr}(&t, &t);
|
137
|
-
~
|
138
|
-
|
139
|
-
test :pushNULLPtr, %~
|
140
|
-
#{ctor}(&t, "XYZ");
|
141
|
-
#{pushPtr}(&t, NULL);
|
142
|
-
~
|
143
|
-
|
144
|
-
test :pushFormat, %~
|
145
|
-
#{ctor}(&t, NULL);
|
146
|
-
#{pushFormat}(&t, "%s%c%d", "XY", 'Z', -123);
|
147
|
-
TEST_EQUAL_CHARS( #{chars}(&t), "XYZ-123" );
|
148
|
-
~
|
149
|
-
|
150
|
-
setup %~
|
151
|
-
#{type} t;
|
152
|
-
#{char_type}* b = #{malloc}(#{_bufferSize}*sizeof(#{char_type})); #{assert}(b);
|
153
|
-
memset(b, '*', _#{bufferSize});
|
154
|
-
b[#{_bufferSize}-1] = '\\0';
|
155
|
-
~
|
156
|
-
cleanup %~
|
157
|
-
#{free}(b);
|
158
|
-
#{dtor}(&t);
|
159
|
-
~
|
160
|
-
|
161
|
-
test :pushFormatExactBuffer, %~
|
162
|
-
#{ctor}(&t, NULL);
|
163
|
-
#{pushFormat}(&t, "%s", b);
|
164
|
-
TEST_EQUAL_CHARS( #{chars}(&t), b );
|
165
|
-
~
|
166
|
-
|
167
|
-
test :pushFormatOverBuffer, %~
|
168
|
-
#{ctor}(&t, "-");
|
169
|
-
#ifdef AUTOC_VSNPRINTF
|
170
|
-
#{pushFormat}(&t, "%s-", b);
|
171
|
-
TEST_EQUAL(#{size}(&t), #{_bufferSize}+1);
|
172
|
-
#else
|
173
|
-
TEST_MESSAGE("vsnprintf() is not used, skipping")
|
174
|
-
#endif
|
175
|
-
~
|
176
|
-
|
177
|
-
setup %~
|
178
|
-
#{type} t;
|
179
|
-
#{it} it;
|
180
|
-
~
|
181
|
-
cleanup %~#{dtor}(&t);~
|
182
|
-
|
183
|
-
test :iterateOverNULL, %~
|
184
|
-
#{ctor}(&t, NULL);
|
185
|
-
#{itCtor}(&it, &t);
|
186
|
-
TEST_FALSE( #{itMove}(&it) );
|
187
|
-
~
|
188
|
-
|
189
|
-
test :iterateOverEmpty, %~
|
190
|
-
#{ctor}(&t, "");
|
191
|
-
#{itCtor}(&it, &t);
|
192
|
-
TEST_FALSE( #{itMove}(&it) );
|
193
|
-
~
|
194
|
-
|
195
|
-
test :iterateForward, %~
|
196
|
-
#{ctor}(&t, "XYZ");
|
197
|
-
#{itCtor}(&it, &t);
|
198
|
-
TEST_TRUE( #{itMove}(&it) );
|
199
|
-
TEST_EQUAL( #{itGet}(&it), 'X' );
|
200
|
-
TEST_TRUE( #{itMove}(&it) );
|
201
|
-
TEST_EQUAL( #{itGet}(&it), 'Y' );
|
202
|
-
TEST_TRUE( #{itMove}(&it) );
|
203
|
-
TEST_EQUAL( #{itGet}(&it), 'Z' );
|
204
|
-
TEST_FALSE( #{itMove}(&it) );
|
205
|
-
~
|
206
|
-
|
207
|
-
test :iterateBackward, %~
|
208
|
-
#{ctor}(&t, "ZYX");
|
209
|
-
#{itCtorEx}(&it, &t, 0);
|
210
|
-
TEST_TRUE( #{itMove}(&it) );
|
211
|
-
TEST_EQUAL( #{itGet}(&it), 'X' );
|
212
|
-
TEST_TRUE( #{itMove}(&it) );
|
213
|
-
TEST_EQUAL( #{itGet}(&it), 'Y' );
|
214
|
-
TEST_TRUE( #{itMove}(&it) );
|
215
|
-
TEST_EQUAL( #{itGet}(&it), 'Z' );
|
216
|
-
TEST_FALSE( #{itMove}(&it) );
|
217
|
-
~
|
218
|
-
|
219
|
-
setup %~#{type} t1, t2;~
|
220
|
-
cleanup %~#{dtor}(&t1); #{dtor}(&t2);~
|
221
|
-
|
222
|
-
test :copy, %~
|
223
|
-
#{ctor}(&t1, "XYZ");
|
224
|
-
#{copy}(&t2, &t1);
|
225
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
226
|
-
~
|
227
|
-
|
228
|
-
test :copyNULL, %~
|
229
|
-
#{ctor}(&t1, NULL);
|
230
|
-
#{copy}(&t2, &t1);
|
231
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
232
|
-
~
|
233
|
-
|
234
|
-
test :copyEmpty, %~
|
235
|
-
#{ctor}(&t1, "");
|
236
|
-
#{copy}(&t2, &t1);
|
237
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
238
|
-
~
|
239
|
-
|
240
|
-
test :copyFullRange, %~
|
241
|
-
#{ctor}(&t1, "XYZ");
|
242
|
-
#{copyRange}(&t2, &t1, 0, 2);
|
243
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
244
|
-
~
|
245
|
-
|
246
|
-
test :copyPartialRange, %~
|
247
|
-
#{ctor}(&t1, "_XYZ_");
|
248
|
-
#{copyRange}(&t2, &t1, 1, 3);
|
249
|
-
TEST_EQUAL_CHARS( #{chars}(&t2), "XYZ" );
|
250
|
-
~
|
251
|
-
|
252
|
-
test :copySingleCharRange, %~
|
253
|
-
#{ctor}(&t1, "XYZ");
|
254
|
-
#{copyRange}(&t2, &t1, 1, 1);
|
255
|
-
TEST_EQUAL_CHARS( #{chars}(&t2), "Y" );
|
256
|
-
~
|
257
|
-
|
258
|
-
test :equal, %~
|
259
|
-
#{ctor}(&t1, "XYZ");
|
260
|
-
#{ctor}(&t2, "XYZ");
|
261
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
262
|
-
~
|
263
|
-
|
264
|
-
test :notEqual, %~
|
265
|
-
#{ctor}(&t1, "-XYZ");
|
266
|
-
#{ctor}(&t2, "XYZ-");
|
267
|
-
TEST_FALSE( #{equal}(&t1, &t2) );
|
268
|
-
~
|
269
|
-
|
270
|
-
end
|
data/test/test_int_list.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
type_test(AutoC::List, :IntList, :int) do
|
2
|
-
|
3
|
-
setup %~#{type} t;~
|
4
|
-
cleanup %~#{dtor}(&t);~
|
5
|
-
|
6
|
-
test :create, %~
|
7
|
-
#{ctor}(&t);
|
8
|
-
TEST_TRUE( #{empty}(&t) );
|
9
|
-
TEST_EQUAL( #{size}(&t), 0 );
|
10
|
-
~
|
11
|
-
|
12
|
-
setup %~
|
13
|
-
int i, c = 3;
|
14
|
-
#{type} t1, t2;
|
15
|
-
#{ctor}(&t1);
|
16
|
-
#{ctor}(&t2);
|
17
|
-
for(i = 0; i < c; ++i) {
|
18
|
-
#{push}(&t1, i);
|
19
|
-
#{push}(&t2, i);
|
20
|
-
}
|
21
|
-
~
|
22
|
-
cleanup %~
|
23
|
-
#{dtor}(&t1);
|
24
|
-
#{dtor}(&t2);
|
25
|
-
~
|
26
|
-
|
27
|
-
test :equal, %~
|
28
|
-
TEST_EQUAL( #{size}(&t1), #{size}(&t2) );
|
29
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
30
|
-
#{push}(&t2, -1);
|
31
|
-
TEST_NOT_EQUAL( #{size}(&t1), #{size}(&t2) );
|
32
|
-
TEST_FALSE( #{equal}(&t1, &t2) );
|
33
|
-
~
|
34
|
-
|
35
|
-
end
|
data/test/test_int_tree_set.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
type_test(AutoC::TreeSet, :IntTreeSet, :int) do
|
2
|
-
|
3
|
-
setup %~#{type} t; #{ctor}(&t);~
|
4
|
-
cleanup %~#{dtor}(&t);~
|
5
|
-
|
6
|
-
test :create, %~
|
7
|
-
TEST_TRUE( #{empty}(&t) );
|
8
|
-
TEST_EQUAL( #{size}(&t), 0 );
|
9
|
-
~
|
10
|
-
|
11
|
-
test :put, %~
|
12
|
-
TEST_EQUAL( #{size}(&t), 0 );
|
13
|
-
TEST_FALSE( #{contains}(&t, 1) );
|
14
|
-
TEST_TRUE( #{put}(&t, 1) );
|
15
|
-
TEST_TRUE( #{contains}(&t, 1) );
|
16
|
-
TEST_FALSE( #{put}(&t, 1) );
|
17
|
-
TEST_EQUAL( #{size}(&t), 1 );
|
18
|
-
TEST_TRUE( #{put}(&t, -1) );
|
19
|
-
TEST_TRUE( #{put}(&t, 2) );
|
20
|
-
TEST_EQUAL( #{size}(&t), 3 );
|
21
|
-
TEST_FALSE( #{contains}(&t, 0) );
|
22
|
-
~
|
23
|
-
|
24
|
-
setup %~
|
25
|
-
int i, c = 3;
|
26
|
-
#{type} t1, t2;
|
27
|
-
#{ctor}(&t1);
|
28
|
-
#{ctor}(&t2);
|
29
|
-
for(i = 0; i < c; ++i) {
|
30
|
-
#{put}(&t1, i);
|
31
|
-
#{put}(&t2, i);
|
32
|
-
}
|
33
|
-
~
|
34
|
-
cleanup %~
|
35
|
-
#{dtor}(&t1);
|
36
|
-
#{dtor}(&t2);
|
37
|
-
~
|
38
|
-
|
39
|
-
test :equal, %~
|
40
|
-
TEST_EQUAL( #{size}(&t1), #{size}(&t2) );
|
41
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
42
|
-
#{put}(&t2, -1);
|
43
|
-
TEST_NOT_EQUAL( #{size}(&t1), #{size}(&t2) );
|
44
|
-
TEST_FALSE( #{equal}(&t1, &t2) );
|
45
|
-
~
|
46
|
-
|
47
|
-
setup %~
|
48
|
-
int values[] = {2,-6,7,-6,1,2,5,7,4,3,1,-6,0};
|
49
|
-
int* p = values;
|
50
|
-
#{type} t;
|
51
|
-
#{ctor}(&t);
|
52
|
-
while(*p != 0) {
|
53
|
-
#{put}(&t, *p);
|
54
|
-
TEST_TRUE( #{contains}(&t, *p) );
|
55
|
-
++p;
|
56
|
-
}
|
57
|
-
~
|
58
|
-
cleanup %~
|
59
|
-
#{dtor}(&t);
|
60
|
-
~
|
61
|
-
|
62
|
-
test :size, %~
|
63
|
-
TEST_EQUAL( #{size}(&t), 7 );
|
64
|
-
~
|
65
|
-
|
66
|
-
test :contains, %~
|
67
|
-
TEST_TRUE( #{contains}(&t, 1) );
|
68
|
-
TEST_FALSE( #{contains}(&t, -1) );
|
69
|
-
~
|
70
|
-
|
71
|
-
test :iterateAscending, %~
|
72
|
-
int cur, pre, start = 1;
|
73
|
-
#{it} it;
|
74
|
-
#{itCtorEx}(&it, &t, 1);
|
75
|
-
cur = pre = #{peekLowest}(&t);
|
76
|
-
while(#{itMove}(&it)) {
|
77
|
-
cur = #{itGet}(&it);
|
78
|
-
if(start) {
|
79
|
-
start = 0;
|
80
|
-
} else {
|
81
|
-
TEST_TRUE( pre < cur );
|
82
|
-
pre = cur;
|
83
|
-
}
|
84
|
-
}
|
85
|
-
~
|
86
|
-
|
87
|
-
test :iterateDescending, %~
|
88
|
-
int cur, pre, start = 1;
|
89
|
-
#{it} it;
|
90
|
-
#{itCtorEx}(&it, &t, 0);
|
91
|
-
cur = pre = #{peekHighest}(&t);
|
92
|
-
while(#{itMove}(&it)) {
|
93
|
-
cur = #{itGet}(&it);
|
94
|
-
if(start) {
|
95
|
-
start = 0;
|
96
|
-
} else {
|
97
|
-
TEST_TRUE( pre > cur );
|
98
|
-
pre = cur;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
~
|
102
|
-
|
103
|
-
test :peekHighest, %~
|
104
|
-
TEST_EQUAL( #{peekHighest}(&t), 7 );
|
105
|
-
~
|
106
|
-
|
107
|
-
test :peekLowest, %~
|
108
|
-
TEST_EQUAL( #{peekLowest}(&t), -6 );
|
109
|
-
~
|
110
|
-
|
111
|
-
end
|
data/test/test_int_vector.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
type_test(AutoC::Vector, :IntVector, :int) do
|
2
|
-
|
3
|
-
setup %~
|
4
|
-
#{type} t1, t2;
|
5
|
-
#{element.type} e;
|
6
|
-
int i, c = 3;
|
7
|
-
#{ctor}(&t1, c);
|
8
|
-
#{ctor}(&t2, c);
|
9
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
10
|
-
for(i = 0; i < c; ++i) {
|
11
|
-
#{set}(&t1, i, i);
|
12
|
-
#{set}(&t2, i, i);
|
13
|
-
}
|
14
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
15
|
-
~
|
16
|
-
cleanup %~
|
17
|
-
#{dtor}(&t1);
|
18
|
-
#{dtor}(&t2);
|
19
|
-
~
|
20
|
-
|
21
|
-
test :sort, %~
|
22
|
-
#{sortEx}(&t2, 0);
|
23
|
-
/* 2,1,0 */
|
24
|
-
TEST_FALSE( #{equal}(&t1, &t2) );
|
25
|
-
TEST_EQUAL( #{get}(&t2, 0), 2 );
|
26
|
-
TEST_EQUAL( #{get}(&t2, 1), 1 );
|
27
|
-
#{sortEx}(&t2, 1);
|
28
|
-
/* 0,1,2 */
|
29
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
30
|
-
TEST_EQUAL( #{get}(&t2, 0), 0 );
|
31
|
-
TEST_EQUAL( #{get}(&t2, 1), 1 );
|
32
|
-
~
|
33
|
-
|
34
|
-
end
|
data/test/test_value_hash_map.rb
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
require "value"
|
2
|
-
|
3
|
-
type_test(AutoC::HashMap, :ValueHashMap, Value, Value) do
|
4
|
-
|
5
|
-
def write_defs(stream)
|
6
|
-
stream << %~
|
7
|
-
#undef PUT
|
8
|
-
#define PUT(t, k, v) {#{key.type} ek; #{value.type} ev; #{key.ctorEx}(ek, k); #{value.ctorEx}(ev, v); #{put}(t, ek, ev); #{key.dtor}(ek); #{value.dtor}(ev);}
|
9
|
-
~
|
10
|
-
super
|
11
|
-
end
|
12
|
-
|
13
|
-
setup %~#{type} t;~
|
14
|
-
cleanup %~#{dtor}(&t);~
|
15
|
-
|
16
|
-
test :create, %~
|
17
|
-
#{ctor}(&t);
|
18
|
-
TEST_EQUAL( #{size}(&t), 0 );
|
19
|
-
TEST_TRUE( #{empty}(&t) );
|
20
|
-
~
|
21
|
-
|
22
|
-
test :purge, %~
|
23
|
-
#{ctor}(&t);
|
24
|
-
PUT(&t, 0, 0);
|
25
|
-
TEST_FALSE( #{empty}(&t) );
|
26
|
-
#{purge}(&t);
|
27
|
-
TEST_TRUE( #{empty}(&t) );
|
28
|
-
~
|
29
|
-
|
30
|
-
test :empty, %~
|
31
|
-
#{ctor}(&t);
|
32
|
-
TEST_TRUE( #{empty}(&t) );
|
33
|
-
PUT(&t, 1, -1);
|
34
|
-
TEST_FALSE( #{empty}(&t) );
|
35
|
-
~
|
36
|
-
|
37
|
-
test :size, %~
|
38
|
-
#{ctor}(&t);
|
39
|
-
TEST_TRUE( #{empty}(&t) );
|
40
|
-
TEST_EQUAL( #{size}(&t), 0 );
|
41
|
-
PUT(&t, 1, -1);
|
42
|
-
TEST_FALSE( #{empty}(&t) );
|
43
|
-
TEST_EQUAL( #{size}(&t), 1 );
|
44
|
-
~
|
45
|
-
|
46
|
-
setup %~
|
47
|
-
/* {i => -i} */
|
48
|
-
int i, c = 3;
|
49
|
-
#{type} t;
|
50
|
-
#{key.type} k;
|
51
|
-
#{element.type} v;
|
52
|
-
#{ctor}(&t);
|
53
|
-
for(i = 1; i <= c; i++) {
|
54
|
-
PUT(&t, i, -i);
|
55
|
-
}
|
56
|
-
~
|
57
|
-
cleanup %~
|
58
|
-
#{dtor}(&t);
|
59
|
-
~
|
60
|
-
|
61
|
-
test :copy, %~
|
62
|
-
#{type} t2;
|
63
|
-
#{copy}(&t2, &t);
|
64
|
-
TEST_TRUE( #{equal}(&t2, &t) );
|
65
|
-
#{dtor}(&t2);
|
66
|
-
~
|
67
|
-
|
68
|
-
test :equal, %~
|
69
|
-
#{type} t2;
|
70
|
-
#{copy}(&t2, &t);
|
71
|
-
TEST_TRUE( #{equal}(&t2, &t) );
|
72
|
-
PUT(&t2, -1, 1);
|
73
|
-
TEST_FALSE( #{equal}(&t2, &t) );
|
74
|
-
#{dtor}(&t2);
|
75
|
-
~
|
76
|
-
|
77
|
-
test :containsKey, %~
|
78
|
-
#{element.ctor(:k)};
|
79
|
-
#{element.set}(k, 0);
|
80
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
81
|
-
#{element.set}(k, 1);
|
82
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
83
|
-
#{element.dtor(:k)};
|
84
|
-
~
|
85
|
-
|
86
|
-
test :get, %~
|
87
|
-
#{element.ctor(:k)};
|
88
|
-
#{element.set}(k, 3);
|
89
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
90
|
-
v = #{get}(&t, k);
|
91
|
-
TEST_EQUAL( #{element.get}(v), -3 );
|
92
|
-
#{element.dtor(:v)};
|
93
|
-
#{element.dtor(:k)};
|
94
|
-
~
|
95
|
-
|
96
|
-
test :putNew, %~
|
97
|
-
#{element.ctor(:k)};
|
98
|
-
#{element.set}(k, 0);
|
99
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
100
|
-
TEST_TRUE( #{put}(&t, k, k) ) ;
|
101
|
-
#{element.dtor(:k)};
|
102
|
-
~
|
103
|
-
|
104
|
-
test :putExisting, %~
|
105
|
-
#{element.ctor(:k)};
|
106
|
-
#{element.set}(k, 1);
|
107
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
108
|
-
TEST_FALSE( #{put}(&t, k, k) ) ;
|
109
|
-
#{element.dtor(:k)};
|
110
|
-
~
|
111
|
-
|
112
|
-
test :remove, %~
|
113
|
-
#{element.ctor(:k)};
|
114
|
-
#{element.set}(k, 1);
|
115
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
116
|
-
TEST_TRUE( #{remove}(&t, k) ) ;
|
117
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
118
|
-
#{element.dtor(:k)};
|
119
|
-
~
|
120
|
-
|
121
|
-
test :removeNone, %~
|
122
|
-
#{element.ctor(:k)};
|
123
|
-
#{element.set}(k, 0);
|
124
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
125
|
-
TEST_FALSE( #{remove}(&t, k) ) ;
|
126
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
127
|
-
#{element.dtor(:k)};
|
128
|
-
~
|
129
|
-
|
130
|
-
test :replace, %~
|
131
|
-
#{element.ctor(:k)};
|
132
|
-
#{element.set}(k, 1);
|
133
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
134
|
-
TEST_TRUE( #{replace}(&t, k, k) ) ;
|
135
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
136
|
-
#{element.dtor(:k)};
|
137
|
-
~
|
138
|
-
|
139
|
-
test :replaceNone, %~
|
140
|
-
#{element.ctor(:k)};
|
141
|
-
#{element.set}(k, 0);
|
142
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
143
|
-
TEST_FALSE( #{replace}(&t, k, k) ) ;
|
144
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
145
|
-
#{element.dtor(:k)};
|
146
|
-
~
|
147
|
-
|
148
|
-
test :iterate, %~
|
149
|
-
#{it} it;
|
150
|
-
#{itCtor}(&it, &t);
|
151
|
-
while(#{itMove}(&it)) {
|
152
|
-
#{key.type} k;
|
153
|
-
#{element.type} v;
|
154
|
-
k = #{itGetKey}(&it);
|
155
|
-
v = #{itGetElement}(&it);
|
156
|
-
TEST_EQUAL( #{key.get}(k), -#{value.get}(v) );
|
157
|
-
#{key.dtor}(k);
|
158
|
-
#{value.dtor}(v);
|
159
|
-
}
|
160
|
-
~
|
161
|
-
|
162
|
-
end
|