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
|
package require tcltest
namespace import -force tcltest::*
set CFLAGS {-O3}
test long_int64_1 {Test of long keys and int64 values} -setup {
exec gcc $CFLAGS -o test testl64.c
} -body {
exec ./test
} -result {mymap[1]=2
mymap[101]=202 mymap[1]=2 mymap[42]=83
mymap[42]=84
mymap[1024]=2048
mymap[1024]=0
mymap[10]=0
mymap[1] = 2
mymap[42] = 84
mymap[101] = 202
mymap[42] = 84
mymap[101] = 202
mymap[101] = 202
mymap[10]=20
mymap[0] = 100
mymap[1] = 102
mymap[2] = 104
mymap[3] = 106
mymap[5] = 1005
mymap[382] = 1382
mymap[526] = 1526
mymap[903] = 1903
mymap[5] = 1005
mymap[526] = 1526
mymap[903] = 1903
mymap[526] = 1526
mymap[903] = 1903
mymap[526] = 1526
}
test long_int64_2 {Range test of long keys and int64 values} -setup {
exec gcc $CFLAGS -o test testl64R.c
} -body {
exec ./test
} -result {mymap[1] = -9223372036854775808
mymap[2] = 9223372036854775807
mymap[4] = -1
mymap[5] = 5
mymap[999996] = 1999992
mymap[999997] = 1999994
mymap[999998] = 1999996
mymap[999999] = 1999998}
# same test as long_int64_1, except dynamic alloc
test long_int64_3 {Test of long keys and int64 values, dynamic allocation} -setup {
exec gcc $CFLAGS -o test testl64_alloc.c
} -body {
exec ./test
} -result {mymap[1]=2
mymap[101]=202 mymap[1]=2 mymap[42]=83
mymap[42]=84
mymap[1024]=2048
mymap[1024]=0
mymap[10]=0
mymap[1] = 2
mymap[42] = 84
mymap[101] = 202
mymap[42] = 84
mymap[101] = 202
mymap[101] = 202
mymap[10]=20
mymap[10] = 20
mymap[0] = 100
mymap[1] = 102
mymap[2] = 104
mymap[3] = 106
mymap[5] = 1005
mymap[382] = 1382
mymap[526] = 1526
mymap[903] = 1903
mymap[5] = 1005
mymap[526] = 1526
mymap[903] = 1903
mymap[526] = 1526
mymap[903] = 1903
mymap[526] = 1526
}
test long_long_int64_1 {Test of long,long keys and int64 values} -setup {
exec gcc $CFLAGS -o test testll64.c
} -body {
exec ./test
} -result {mymap[1,1]=1
mymap[1,2]=2
mymap[2,1]=3
mymap[1,1] = 1
mymap[1,2] = 2
mymap[2,1] = 3}
test str_int64_4 {Test of string keys and int64 values} -setup {
exec gcc $CFLAGS -o test teststr.c
} -body {
exec ./test
} -result {mymap[two]=2
mymap[two-oh-two]=202 mymap[two]=2 mymap[eighty-four]=83
mymap[eighty-four]=84
mymap[two] = 2
mymap[eighty-four] = 84
mymap[two-oh-two] = 202
mymap[0123456789] = 1000000
mymap[2048]=2048
mymap[2048]=0
mymap[10]=0
mymap[eighty-four] = 84
mymap[two-oh-two] = 202
mymap[0123456789] = 1000000
mymap[eighty-four] = 84
mymap[0123456789] = 1000000
mymap[0123456789] = 1000000
mymap[Ohio]=10123456
mymap[Ohio] = 10123456
mymap[test_number_0] = 1000
mymap[test_number_1] = 1001
mymap[test_number_2] = 1002
mymap[test_number_3] = 1003}
test str_str_int64_1 {Test of string,string keys and int64 values} -setup {
exec gcc $CFLAGS -o test teststrstr.c
} -body {
exec ./test
} -result {mymap[two,three]=6
mymap[two-oh-two,four]=808 mymap[two,three]=6 mymap[eighty-four,two]=167
mymap[eighty-four,two]=168
mymap[two,three] = 6
mymap[eighty-four,two] = 168
mymap[two-oh-two,four] = 808
mymap[0123456789,foo] = 1000000
mymap[2048,2]=4096
mymap[2048,2]=0
mymap[10,six]=0
mymap[eighty-four,two] = 168
mymap[two-oh-two,four] = 808
mymap[0123456789,foo] = 1000000
mymap[eighty-four,two] = 168
mymap[0123456789,foo] = 1000000
mymap[eighty-four,two] = 168
mymap[0123456789,foo] = 1000000
mymap[Ohio,1801] = 10123456
mymap[test_number_2,**test number 4**] = 8
mymap[test_number_3,**test number 9**] = 27
mymap[test_number_4,**test number 16**] = 64
mymap[test_number_5,**test number 25**] = 125}
test str_long_int64_1 {Test of string,long keys and int64 values} -setup {
exec gcc $CFLAGS -o test teststrlong.c
} -body {
exec ./test
} -result {map[two,3]=6
map[two-oh-two,4]=808
map[two,3]=6
map[eighty-four,2]=167
map[eighty-four,2]=168
map[two,3] = 6
map[eighty-four,2] = 168
map[two-oh-two,4] = 808
map[0123456789,4444] = 1000000
map[2048,2]=4096
mymap[2048,2]=0
mymap[six,10]=0
map[eighty-four,2] = 168
map[two-oh-two,4] = 808
map[0123456789,4444] = 1000000
map[eighty-four,2] = 168
map[0123456789,4444] = 1000000
map[eighty-four,2] = 168
map[0123456789,4444] = 1000000
map[Ohio,1801] = 10123456
map[test_number_2,2] = 8
map[test_number_3,3] = 27
map[test_number_4,4] = 64
map[test_number_5,5] = 125
Should be empty:
}
test long_str_int64_1 {Test of long,string keys and int64 values} -setup {
exec gcc $CFLAGS -o test testlongstr.c
} -body {
exec ./test
} -result {map[3,two]=6
map[4,two-oh-two]=808
map[3,two]=6
map[2,eighty-four]=167
map[2,eighty-four]=168
map[3,two] = 6
map[2,eighty-four] = 168
map[4,two-oh-two] = 808
map[4444,0123456789] = 1000000
map[2048,2]=4096
mymap[2048,2]=0
mymap[10,six]=0
map[2,eighty-four] = 168
map[4,two-oh-two] = 808
map[4444,0123456789] = 1000000
map[2,eighty-four] = 168
map[4444,0123456789] = 1000000
map[2,eighty-four] = 168
map[1801,Ohio] = 10123456
map[2,test_number_2] = 8
map[3,test_number_3] = 27
map[4,test_number_4] = 64
map[5,test_number_5] = 125
Should be empty:
}
test str_str_str_1 {Test of string,string keys and string values} -setup {
exec gcc $CFLAGS -o test teststrstrstr.c
} -body {
exec ./test
} -result {map[two,2]=four
map[two-two-one-B,Baker Street]=7% solution
map[two,2]=four
map[eighty-four,nineteen hundred]=nineteen hundred and eighty-three
map[eighty-four,nineteen hundred]=nineteen hundred and eighty-four
map[two,2] = four
map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four
map[two-two-one-B,Baker Street] = 7% solution
map[0123456789,4444] = 1000000
map[2048,2]=4096
mymap[2048,2]=(null)
mymap[six,10]=(null)
map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four
map[two-two-one-B,Baker Street] = 7% solution
map[0123456789,4444] = 1000000
map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four
map[0123456789,4444] = 1000000
map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four
map[0123456789,4444] = 1000000
map[abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ,(null)] = TESTING 1,2,3
map[abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZhiasdhgfiudsgfiusdgfisdugfisdugfsdiufgsdfiugsdifugsdiufgsdiufgisdugfisdugfigsdfiusdgfiugsdifu sdfigsdifugsdifugsdiufgsdiufgisdugfiudsgfisudgfiusdgfiusdgfisdugfisdufgiusdfgsdiufgdsiufgsdiufgsdiufgsdiufgwiugfw89e4rf98yf897ywef98wyef98wyf98wyf89ys9d8yfsd sdfysd98fy9s8fyds98fy98dsfy89sdfy,yw98fty98sfts98d7fts89d7f9sdfoooooooooooooooooooooooooooooooooooooooooooof8eo7stfew87fwet8tw87rf7fpowft7ewfptpwefpwetfpwepwfwetfp8we] = TESTING 1,2,3 ***************************************************************************************************************************************************************************************************************************************************************************** 4,5,6
map[test_number_2,TEST_NUMBER_4] = TEST_NUMBER_8
map[test_number_3,TEST_NUMBER_9] = TEST_NUMBER_27
map[test_number_4,TEST_NUMBER_16] = TEST_NUMBER_64
map[test_number_5,TEST_NUMBER_25] = TEST_NUMBER_125
Should be empty:
}
test stat_1 {Test of string,long keys and stat values} -setup {
exec gcc $CFLAGS -o test teststat.c
} -body {
exec ./test
} -result {map[created with set,2001] = [c=5 s=125 minmax =2,42]
map[created with set,2001] = [c=6 s=142 minmax =2,42]
map[created with add,2020] = [c=1 s=1700 minmax =1700,1700]
map[created with add,2020] = [c=2 s=1702 minmax =2,1700]
map[created with add,2020] = [c=3 s=4047 minmax =2,2345]
map[created with set,2001] = [c=6 s=142 minmax =2,42]
map[created with add,2020] = [c=3 s=4047 minmax =2,2345]
map[created with add,2020] = [c=3 s=4047 minmax =2,2345]
map[created with add,2020] = [c=5 s=123456 minmax =2,42]
map[created with add,1234] = [c=2 s=100 minmax =42,58]
map[created with add,1234] = [c=2 s=100 minmax =42,58]
}
test list_1 {Test of List of string values} -setup {
exec gcc $CFLAGS -o test testlist.c
} -body {
exec ./test
} -result {map[0] = Item0
map[1] = Item1
map[2] = Item2
map[3] = Item3
map[4] = Item4
map[5] = Item5
map[6] = Item6
map[7] = Item7
map[8] = Item8
map[9] = Item9
size is 10
map[0] = Item0
map[1] = Item1
map[2] = Item2
map[3] = Item3
map[4] = Item4
map[5] = Item5
map[6] = Item6
map[7] = Item7
map[8] = Item8
map[9] = Item9
map[0] = Item0
map[1] = Item1
map[2] = Item2
map[3] = Item3
map[4] = Item4
map[5] = Item5
map[6] = Item6
map[7] = Item7
map[8] = Item8
map[9] = Item9
map[0] = Item50
map[1] = Item51
map[2] = Item52
map[3] = Item53
map[4] = Item54
}
exec rm test
cleanupTests
|