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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
|
package require tcltest
namespace import -force tcltest::*
cd $tcltest::testsDirectory
set CFLAGS "-Os"
set KPATH "/lib/modules/[exec uname -r]/build/include"
set MPATH "/lib/modules/[exec uname -r]/build/include/asm/mach-default"
set PATH "../../user"
test isx {Test of int64 keys and stat values} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test isx.c
} -body {
exec ./test
} -result {map[3] = count:49600 sum:3288450 avg:66 min:0 max:99
value |-------------------------------------------------- count
0 |@@ 460
10 |@@@@@@@ 1460
20 |@@@@@@@@@@@@ 2460
30 |@@@@@@@@@@@@@@@@@@ 3460
40 |@@@@@@@@@@@@@@@@@@@@@@@ 4460
50 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5460
60 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6460
70 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7460
80 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8460
90 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9460
map[2] = count:100 sum:2025 avg:20 min:0 max:81
value |-------------------------------------------------- count
0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 42
10 |@@@@@@@@@@@@@@@@@ 17
20 |@@@@@@@@@@@@@ 13
30 |@@@@@@@@@ 9
40 |@@@@@@@@@ 9
50 |@@@@ 4
60 |@@@ 3
70 |@@ 2
80 |@ 1
90 | 0
map[1] = count:45 sum:2850 avg:63 min:10 max:90
value |-------------------------------------------------- count
0 | 0
10 |@ 1
20 |@@ 2
30 |@@@ 3
40 |@@@@ 4
50 |@@@@@ 5
60 |@@@@@@ 6
70 |@@@@@@@ 7
80 |@@@@@@@@ 8
90 |@@@@@@@@@ 9
map2[1] = count:16384 sum:1040384 avg:63 min:0 max:127
value |-------------------------------------------------- count
0 | 128
1 | 128
2 |@ 256
4 |@@@ 512
8 |@@@@@@ 1024
16 |@@@@@@@@@@@@ 2048
32 |@@@@@@@@@@@@@@@@@@@@@@@@ 4096
64 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8192
128 | 0
256 | 0
map2[2] = count:1048576 sum:536346624 avg:511 min:0 max:1023
value |-------------------------------------------------- count
0 | 1024
1 | 1024
2 | 2048
4 | 4096
8 | 8192
16 |@ 16384
32 |@@@ 32768
64 |@@@@@@ 65536
128 |@@@@@@@@@@@@ 131072
256 |@@@@@@@@@@@@@@@@@@@@@@@@ 262144
512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 524288
}
test map_format {Torture test of map formatting} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test map_format.c
} -body {
exec ./test
} -result {Columbus -> mapiis 1 2 Ohio
Sacramento -> mapiis 3 4 California
Olympia -> mapiis 5 6 Washington
Salem -> mapiis 7 8 Oregon
Columbus % Ohio
Sacramento % California
Olympia % Washington
Salem % Oregon
Columbus -> mapiis
Sacramento -> mapiis
Olympia -> mapiis
Salem -> mapiis
The capitol of Riga is Latvia and the nerd population is 212063400820736
The capitol of Sofia is Bulgaria and the nerd population is -2400999087387945352
The capitol of Valletta is Malta and the nerd population is 1
The capitol of Nicosia is Cyprus and the nerd population is -1
The capitol of Riga is Latvia and the nerd population is c0dedbad0000
The capitol of Sofia is Bulgaria and the nerd population is deadf00d12345678
The capitol of Valletta is Malta and the nerd population is 1
The capitol of Nicosia is Cyprus and the nerd population is ffffffffffffffff
The capitol of Riga is Latvia and the nerd population is C0DEDBAD0000
The capitol of Sofia is Bulgaria and the nerd population is DEADF00D12345678
The capitol of Valletta is Malta and the nerd population is 1
The capitol of Nicosia is Cyprus and the nerd population is FFFFFFFFFFFFFFFF
Bogons per packet for Riga
count:49600 sum:3288450 avg:66 min:0 max:99
value |-------------------------------------------------- count
0 |@@ 460
10 |@@@@@@@ 1460
20 |@@@@@@@@@@@@ 2460
30 |@@@@@@@@@@@@@@@@@@ 3460
40 |@@@@@@@@@@@@@@@@@@@@@@@ 4460
50 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5460
60 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6460
70 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7460
80 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8460
90 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9460
Bogons per packet for Sofia
count:100 sum:2025 avg:20 min:0 max:81
value |-------------------------------------------------- count
0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 42
10 |@@@@@@@@@@@@@@@@@ 17
20 |@@@@@@@@@@@@@ 13
30 |@@@@@@@@@ 9
40 |@@@@@@@@@ 9
50 |@@@@ 4
60 |@@@ 3
70 |@@ 2
80 |@ 1
90 | 0
Bogons per packet for Valletta
count:45 sum:2850 avg:63 min:10 max:90
value |-------------------------------------------------- count
0 | 0
10 |@ 1
20 |@@ 2
30 |@@@ 3
40 |@@@@ 4
50 |@@@@@ 5
60 |@@@@@@ 6
70 |@@@@@@@ 7
80 |@@@@@@@@ 8
90 |@@@@@@@@@ 9
49600 was the count for Riga, Latvia
100 was the count for Sofia, Bulgaria
45 was the count for Valletta, Malta
mapsst[ Riga, Latvia] = 322D82
mapsst[ Sofia, Bulgaria] = 7E9
mapsst[ Valletta, Malta] = B22}
test map_issii {Test of int64,string,string,int64 keys and int64 values} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test issii.c
} -body {
exec ./test
} -result {map[1, Boston, MA, 1970] = 5224303
map[2, Boston, MA, 2000] = 6057826
map[3, Chicago, IL, 2000] = 8272768
1. The population of Boston, MA in 1970 was 5224303
2. The population of Boston, MA in 2000 was 6057826
3. The population of Chicago, IL in 2000 was 8272768
}
test map_sort {Test of sorting} -setup {
puts "gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test sort.c"
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test sort.c
} -body {
exec ./test
} -result {sorting from A-Z on value
Boston -> 5 5 Massachusetts
Carson City -> 7 8 Nevada
Columbus -> 1 2 Ohio
Des Moines -> 8 8 Iowa
Montpelier -> 2 2 Vermont
Olympia -> 5 6 Washington
Raleigh -> -1 9 North Carolina
Sacramento -> 3 4 California
Salem -> 7 8 Oregon
Santa Fe -> 1 4 New Mexico
sorting from Z-A on value
Santa Fe -> 1 4 New Mexico
Salem -> 7 8 Oregon
Sacramento -> 3 4 California
Raleigh -> -1 9 North Carolina
Olympia -> 5 6 Washington
Montpelier -> 2 2 Vermont
Des Moines -> 8 8 Iowa
Columbus -> 1 2 Ohio
Carson City -> 7 8 Nevada
Boston -> 5 5 Massachusetts
sorting from low to high on key 1
-1 9 North Carolina -> Raleigh
1 4 New Mexico -> Santa Fe
1 2 Ohio -> Columbus
2 2 Vermont -> Montpelier
3 4 California -> Sacramento
5 6 Washington -> Olympia
5 5 Massachusetts -> Boston
7 8 Oregon -> Salem
7 8 Nevada -> Carson City
8 8 Iowa -> Des Moines
sorting from high to low on key 1
8 8 Iowa -> Des Moines
7 8 Oregon -> Salem
7 8 Nevada -> Carson City
5 6 Washington -> Olympia
5 5 Massachusetts -> Boston
3 4 California -> Sacramento
2 2 Vermont -> Montpelier
1 4 New Mexico -> Santa Fe
1 2 Ohio -> Columbus
-1 9 North Carolina -> Raleigh
sorting from low to high on key 2
2 2 Vermont -> Montpelier
1 2 Ohio -> Columbus
3 4 California -> Sacramento
1 4 New Mexico -> Santa Fe
5 5 Massachusetts -> Boston
5 6 Washington -> Olympia
8 8 Iowa -> Des Moines
7 8 Oregon -> Salem
7 8 Nevada -> Carson City
-1 9 North Carolina -> Raleigh
sorting from high to low on key 2
-1 9 North Carolina -> Raleigh
8 8 Iowa -> Des Moines
7 8 Oregon -> Salem
7 8 Nevada -> Carson City
5 6 Washington -> Olympia
5 5 Massachusetts -> Boston
3 4 California -> Sacramento
1 4 New Mexico -> Santa Fe
2 2 Vermont -> Montpelier
1 2 Ohio -> Columbus
sorting from low to high on key 3
California 3 4 -> Sacramento
Iowa 8 8 -> Des Moines
Massachusetts 5 5 -> Boston
Nevada 7 8 -> Carson City
New Mexico 1 4 -> Santa Fe
North Carolina -1 9 -> Raleigh
Ohio 1 2 -> Columbus
Oregon 7 8 -> Salem
Vermont 2 2 -> Montpelier
Washington 5 6 -> Olympia
sorting from high to low on key 3
Washington 5 6 -> Olympia
Vermont 2 2 -> Montpelier
Oregon 7 8 -> Salem
Ohio 1 2 -> Columbus
North Carolina -1 9 -> Raleigh
New Mexico 1 4 -> Santa Fe
Nevada 7 8 -> Carson City
Massachusetts 5 5 -> Boston
Iowa 8 8 -> Des Moines
California 3 4 -> Sacramento
top 3 alphabetical by value
Boston -> 5 5 Massachusetts
Carson City -> 7 8 Nevada
Columbus -> 1 2 Ohio
bottom 2 alphabetical by value
Santa Fe -> 1 4 New Mexico
Salem -> 7 8 Oregon
top 5 sorted by key 1
8 8 Iowa -> Des Moines
7 8 Oregon -> Salem
7 8 Nevada -> Carson City
5 6 Washington -> Olympia
5 5 Massachusetts -> Boston
bottom 5 sorted by key 1
-1 9 North Carolina -> Raleigh
1 4 New Mexico -> Santa Fe
1 2 Ohio -> Columbus
2 2 Vermont -> Montpelier
3 4 California -> Sacramento
sorted by population from low to high
Nicosia is the capitol of Cyprus and the nerd population is -1
Valletta is the capitol of Malta and the nerd population is 1
Riga is the capitol of Latvia and the nerd population is 135786
Sofia is the capitol of Bulgaria and the nerd population is 138740
sorted by population from high to low
Sofia is the capitol of Bulgaria and the nerd population is 138740
Riga is the capitol of Latvia and the nerd population is 135786
Valletta is the capitol of Malta and the nerd population is 1
Nicosia is the capitol of Cyprus and the nerd population is -1
}
test ii {Test of int64 keys and int64 values} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii.c
} -body {
exec ./test
} -result {map[1]=2
map[1] = 2
map[3] = 4
map[1] = 2
map[3] = 4
0 (should be 0)
map[1] = 2
map[3] = 4
map[5] = 6
map[6] = 106
map[7] = 107
map[8] = 108
map[9] = 109
map[5] = 1005
map[382] = 1382
map[526] = 1526
map[903] = 1903
map[5] = 1005
map[526] = 1526
map[903] = 1903
map[526] = 1526
map[903] = 1903
map[526] = 1526
map[33] = 3333
map[44] = 4444
map[55] = 5555
map[66] = 6666
map[1970] = 1799
}
test is {Test of int64 keys and string values} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test is.c
} -body {
exec ./test
} -result {map[1]=one
map[1] = one
map[1] = one
map[3] = three
map[1] = one
map[3] = three
map[1] = one
map[3] = three
map[1] = one
map[3] = three
map[1024] = 2048
map[1] = one
map[3] = three
map[1] = one
map[3] = three
map[5] = five
map[1] = one
map[3] = three
map[6] = value of 6
map[7] = value of 7
map[8] = value of 8
map[9] = value of 9
map[5] = 1005
map[382] = 1382
map[526] = 1526
map[903] = 1903
map[5] = 1005
map[526] = 1526
map[903] = 1903
map[526] = 1526
map[903] = 1903
map[526] = 1526
map[6] = new value of 6
map[7] = new value of 7
map[8] = new value of 8
map[9] = new value of 9
}
test si {Test of string keys and int64 values} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test si.c
} -body {
exec ./test
} -result {map[Ohio]=1
map[Ohio] = 1
map[Ohio] = 1
map[Washington] = 2
map[Ohio] = 1
map[Washington] = 2
map[Ohio] = 1
map[Washington] = 2
map[1024] = 2048
map[Ohio] = 1
map[Washington] = 2
map[Ohio] = 1
map[Washington] = 2
map[1024] = 2048
map[Ohio] = 1
map[Washington] = 2
map[Ohio] = 1
map[Washington] = 2
map[California] = 3
map[Ohio] = 1
map[Washington] = 2
map[California] = 3
map[] = 7777
map[Ohio] = 1
map[Washington] = 2
map[California] = 3
map[] = 8888
map[Ohio] = 1
map[Washington] = 2
map[California] = 3
map[String 6] = 106
map[String 7] = 107
map[String 8] = 108
map[String 9] = 109
map[String 6] = 106
map[String 7] = 107
map[String 8] = 108
map[String 9] = 109
map[String 6] = 6106
map[String 7] = 7107
map[String 8] = 8108
map[String 9] = 9109
map[String 6] = 6
map[String 7] = 7
map[String 8] = 8
map[String 9] = 9
}
test iiss {Test of int64,int64,string keys and string values} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test iiss.c
} -body {
exec ./test
} -result {map[1, 2, Ohio] = Columbus
map[3, 4, California] = Sacramento
map[5, 6, Washington] = Seattle
map[7, 8, Oregon] = Salem
map[3, 4, California] = Sacramento
map[5, 6, Washington] = Seattle
map[7, 8, Oregon] = Salem
map[-9, -10, Nevada] = Carson City
map[3, 4, California] = Sacramento
map[5, 6, Washington] = Olymp
map[7, 8, Oregon] = Salem
map[-9, -10, Nevada] = Carson City
map[3, 4, California] = Sacramento
map[5, 6, Washington] = Olympis
map[7, 8, Oregon] = Salem
map[-9, -10, Nevada] = Carson City
map[3, 4, California] = Sacramento
map[5, 6, Washington] = Olympia
map[7, 8, Oregon] = Salem
map[-9, -10, Nevada] = Carson City
map[3, 4, California] = Sacramento
map[5, 6, Washington] = Olympia
map[7, 8, Oregon] = Salem
map[3, 4, California] = Sacramento
map[5, 6, Washington] = Olympia
map[7, 8, Oregon] = Salem
}
test setadd {Test of setting and adding values} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test setadd.c
} -body {
exec ./test
} -result {mapi[1] = 1
mapi[2] = 4
mapi[3] = 9
mapi[4] = 16
maps[1] = value of 1
maps[2] = value of 2
maps[3] = value of 3
maps[4] = value of 4
mapx[1] = count:1 sum:1 avg:1 min:1 max:1
mapx[2] = count:1 sum:2 avg:2 min:2 max:2
mapx[3] = count:1 sum:3 avg:3 min:3 max:3
mapx[4] = count:1 sum:4 avg:4 min:4 max:4
mapi[1] = 2
mapi[2] = 8
mapi[3] = 18
mapi[4] = 32
maps[1] = value of 1*****
maps[2] = value of 2*****
maps[3] = value of 3*****
maps[4] = value of 4*****
mapx[1] = count:2 sum:3 avg:1 min:1 max:2
mapx[2] = count:2 sum:6 avg:3 min:2 max:4
mapx[3] = count:2 sum:9 avg:4 min:3 max:6
mapx[4] = count:2 sum:12 avg:6 min:4 max:8
Adding 0
mapi[1] = 2
mapi[2] = 8
mapi[3] = 18
mapi[4] = 32
maps[1] = value of 1*****
maps[2] = value of 2*****
maps[3] = value of 3*****
maps[4] = value of 4*****
maps[1] = value of 1*****
maps[2] = value of 2*****
maps[3] = value of 3*****
maps[4] = value of 4*****
mapx[1] = count:3 sum:3 avg:1 min:0 max:2
mapx[2] = count:3 sum:6 avg:2 min:0 max:4
mapx[3] = count:3 sum:9 avg:3 min:0 max:6
mapx[4] = count:3 sum:12 avg:4 min:0 max:8
Add 'X' to strings
maps[1] = value of 1*****X
maps[2] = value of 2*****X
maps[3] = value of 3*****X
maps[4] = value of 4*****X
setting everything to 0
Adding 0
mapx[1] = count:1 sum:0 avg:0 min:0 max:0
mapx[2] = count:1 sum:0 avg:0 min:0 max:0
mapx[3] = count:1 sum:0 avg:0 min:0 max:0
mapx[4] = count:1 sum:0 avg:0 min:0 max:0
setting everything to -1
mapi[1] = -1
mapi[2] = -1
mapi[3] = -1
mapi[4] = -1
mapx[1] = count:1 sum:-1 avg:-1 min:-1 max:-1
mapx[2] = count:1 sum:-1 avg:-1 min:-1 max:-1
mapx[3] = count:1 sum:-1 avg:-1 min:-1 max:-1
mapx[4] = count:1 sum:-1 avg:-1 min:-1 max:-1
adding -1
mapi[1] = -2
mapi[2] = -2
mapi[3] = -2
mapi[4] = -2
mapx[1] = count:2 sum:-2 avg:-1 min:-1 max:-1
mapx[2] = count:2 sum:-2 avg:-1 min:-1 max:-1
mapx[3] = count:2 sum:-2 avg:-1 min:-1 max:-1
mapx[4] = count:2 sum:-2 avg:-1 min:-1 max:-1
}
test iiiiii {Test of 5 int keys and an int value} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test iiiiii.c
} -body {
exec ./test
} -result {map[1, 2, 3, 4, 5] = 10
map[10, 20, 30, 40, 50] = 100
map[-1, -2, -3, -4, -5] = -10
map[100, 200, 300, 400, 500] = 1000
1 - 2 - 3 - 4 - 5 *** 10
10 - 20 - 30 - 40 - 50 *** 100
-1 - -2 - -3 - -4 - -5 *** -10
100 - 200 - 300 - 400 - 500 *** 1000
}
test ssssss {Test of 5 string keys and a string value} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ssssss.c
} -body {
exec ./test
} -result {map[1ABC, 2ABC, 3ABC, 4ABC, 5ABC] = 666
map[1QRS, 2QRS, 3QRS, 4QRS, 5QRS] = 777
map[1abc, 2abc, 3abc, 4abc, 5abc] = 888
map[1XYZ, 2XYZ, 3XYZ, 4XYZ, 5XYZ] = 999
1ABC and 2ABC and 3ABC and 4ABC and 5ABC ---> 666
1QRS and 2QRS and 3QRS and 4QRS and 5QRS ---> 777
1abc and 2abc and 3abc and 4abc and 5abc ---> 888
1XYZ and 2XYZ and 3XYZ and 4XYZ and 5XYZ ---> 999
}
test sort_stat {Test of sorting stats} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test sort_stat.c
} -body {
exec ./test
} -result {Bogons per packet for California
count:49600 sum:3288450 avg:66 min:0 max:99
value |-------------------------------------------------- count
0 |@@ 460
10 |@@@@@@@ 1460
20 |@@@@@@@@@@@@ 2460
30 |@@@@@@@@@@@@@@@@@@ 3460
40 |@@@@@@@@@@@@@@@@@@@@@@@ 4460
50 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5460
60 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6460
70 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7460
80 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8460
90 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9460
Bogons per packet for Washington
count:100 sum:2025 avg:20 min:0 max:81
value |-------------------------------------------------- count
0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 42
10 |@@@@@@@@@@@@@@@@@ 17
20 |@@@@@@@@@@@@@ 13
30 |@@@@@@@@@ 9
40 |@@@@@@@@@ 9
50 |@@@@ 4
60 |@@@ 3
70 |@@ 2
80 |@ 1
90 | 0
Bogons per packet for Oregon
count:90 sum:5700 avg:63 min:10 max:90
value |-------------------------------------------------- count
0 | 0
10 |@@ 2
20 |@@@@ 4
30 |@@@@@@ 6
40 |@@@@@@@@ 8
50 |@@@@@@@@@@ 10
60 |@@@@@@@@@@@@ 12
70 |@@@@@@@@@@@@@@ 14
80 |@@@@@@@@@@@@@@@@ 16
90 |@@@@@@@@@@@@@@@@@@ 18
Bogons per packet for Nevada
count:45 sum:2970 avg:66 min:10 max:98
value |-------------------------------------------------- count
0 | 0
10 |@ 1
20 |@@ 2
30 |@@@ 3
40 |@@@@ 4
50 |@@@@@ 5
60 |@@@@@@ 6
70 |@@@@@@@ 7
80 |@@@@@@@@ 8
90 |@@@@@@@@@ 9
Bogons per packet for Ohio
count:20 sum:1000 avg:50 min:50 max:50
value |-------------------------------------------------- count
30 | 0
40 | 0
50 |@@@@@@@@@@@@@@@@@@@@ 20
60 | 0
70 | 0
Bogons per packet for North Carolina
count:45 sum:-4200 avg:-93 min:-620 max:100
value |-------------------------------------------------- count
0 |@@@@@@@@@@@@@@@@@@@@@@@@@@ 26
10 |@ 1
20 |@@ 2
30 |@ 1
40 |@@ 2
50 |@ 1
60 |@ 1
70 |@ 1
80 |@ 1
90 |@@@@@@@@@ 9
Bogons per packet for New Mexico
count:450 sum:8475 avg:18 min:-39 max:50
value |-------------------------------------------------- count
0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 145
10 |@@@@@@@@@@@@@@@@@@@ 59
20 |@@@@@@@@@@@@@@@@@@@@@@@ 69
30 |@@@@@@@@@@@@@@@@@@@@@@@@@@ 79
40 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 89
50 |@@@ 9
60 | 0
70 | 0
SORTED BY COUNT
49600 California
450 New Mexico
100 Washington
90 Oregon
45 Nevada
45 North Carolina
20 Ohio
SORTED BY COUNT (low to high)
20 Ohio
45 Nevada
45 North Carolina
90 Oregon
100 Washington
450 New Mexico
49600 California
SORTED BY SUM
3288450 California
8475 New Mexico
5700 Oregon
2970 Nevada
2025 Washington
1000 Ohio
-4200 North Carolina
SORTED BY SUM (low to high)
-4200 North Carolina
1000 Ohio
2025 Washington
2970 Nevada
5700 Oregon
8475 New Mexico
3288450 California
SORTED BY MIN
50 Ohio
10 Nevada
10 Oregon
0 Washington
0 California
-39 New Mexico
-620 North Carolina
SORTED BY MIN (low to high)
-620 North Carolina
-39 New Mexico
0 Washington
0 California
10 Nevada
10 Oregon
50 Ohio
SORTED BY MAX
100 North Carolina
99 California
98 Nevada
90 Oregon
81 Washington
50 New Mexico
50 Ohio
SORTED BY MAX (low to high)
50 New Mexico
50 Ohio
81 Washington
90 Oregon
98 Nevada
99 California
100 North Carolina
SORTED BY AVG
66 Nevada
66 California
63 Oregon
50 Ohio
20 Washington
18 New Mexico
-93 North Carolina
SORTED BY AVG (low to high)
-93 North Carolina
18 New Mexico
20 Washington
50 Ohio
63 Oregon
66 Nevada
66 California
}
test sort2 {Test of sorting (odd number of elements)} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test sort2.c
} -body {
exec ./test
} -result {sorting from A-Z on value
Boston -> 5 5 Massachusetts
Carson City -> 7 8 Nevada
Columbus -> 1 2 Ohio
Des Moines -> 8 8 Iowa
Olympia -> 5 6 Washington
Raleigh -> -1 9 North Carolina
Sacramento -> 3 4 California
Salem -> 7 8 Oregon
Santa Fe -> 1 4 New Mexico
sorting from Z-A on value
Santa Fe -> 1 4 New Mexico
Salem -> 7 8 Oregon
Sacramento -> 3 4 California
Raleigh -> -1 9 North Carolina
Olympia -> 5 6 Washington
Des Moines -> 8 8 Iowa
Columbus -> 1 2 Ohio
Carson City -> 7 8 Nevada
Boston -> 5 5 Massachusetts
sorting from low to high on key 1
-1 9 North Carolina -> Raleigh
1 4 New Mexico -> Santa Fe
1 2 Ohio -> Columbus
3 4 California -> Sacramento
5 6 Washington -> Olympia
5 5 Massachusetts -> Boston
7 8 Oregon -> Salem
7 8 Nevada -> Carson City
8 8 Iowa -> Des Moines
sorting from high to low on key 1
8 8 Iowa -> Des Moines
7 8 Oregon -> Salem
7 8 Nevada -> Carson City
5 6 Washington -> Olympia
5 5 Massachusetts -> Boston
3 4 California -> Sacramento
1 4 New Mexico -> Santa Fe
1 2 Ohio -> Columbus
-1 9 North Carolina -> Raleigh
sorting from low to high on key 2
1 2 Ohio -> Columbus
3 4 California -> Sacramento
1 4 New Mexico -> Santa Fe
5 5 Massachusetts -> Boston
5 6 Washington -> Olympia
8 8 Iowa -> Des Moines
7 8 Oregon -> Salem
7 8 Nevada -> Carson City
-1 9 North Carolina -> Raleigh
sorting from high to low on key 2
-1 9 North Carolina -> Raleigh
8 8 Iowa -> Des Moines
7 8 Oregon -> Salem
7 8 Nevada -> Carson City
5 6 Washington -> Olympia
5 5 Massachusetts -> Boston
3 4 California -> Sacramento
1 4 New Mexico -> Santa Fe
1 2 Ohio -> Columbus
sorting from low to high on key 3
California 3 4 -> Sacramento
Iowa 8 8 -> Des Moines
Massachusetts 5 5 -> Boston
Nevada 7 8 -> Carson City
New Mexico 1 4 -> Santa Fe
North Carolina -1 9 -> Raleigh
Ohio 1 2 -> Columbus
Oregon 7 8 -> Salem
Washington 5 6 -> Olympia
sorting from high to low on key 3
Washington 5 6 -> Olympia
Oregon 7 8 -> Salem
Ohio 1 2 -> Columbus
North Carolina -1 9 -> Raleigh
New Mexico 1 4 -> Santa Fe
Nevada 7 8 -> Carson City
Massachusetts 5 5 -> Boston
Iowa 8 8 -> Des Moines
California 3 4 -> Sacramento
top 3 alphabetical by value
Boston -> 5 5 Massachusetts
Carson City -> 7 8 Nevada
Columbus -> 1 2 Ohio
bottom 2 alphabetical by value
Santa Fe -> 1 4 New Mexico
Salem -> 7 8 Oregon
top 5 sorted by key 1
8 8 Iowa -> Des Moines
7 8 Oregon -> Salem
7 8 Nevada -> Carson City
5 6 Washington -> Olympia
5 5 Massachusetts -> Boston
bottom 5 sorted by key 1
-1 9 North Carolina -> Raleigh
1 4 New Mexico -> Santa Fe
1 2 Ohio -> Columbus
3 4 California -> Sacramento
5 6 Washington -> Olympia
sorted by population from low to high
Nicosia is the capitol of Cyprus and the nerd population is -1
Valletta is the capitol of Malta and the nerd population is 1
Chisinau is the capitol of Moldova and the nerd population is 1024
Riga is the capitol of Latvia and the nerd population is 135786
Sofia is the capitol of Bulgaria and the nerd population is 138740
sorted by population from high to low
Sofia is the capitol of Bulgaria and the nerd population is 138740
Riga is the capitol of Latvia and the nerd population is 135786
Chisinau is the capitol of Moldova and the nerd population is 1024
Valletta is the capitol of Malta and the nerd population is 1
Nicosia is the capitol of Cyprus and the nerd population is -1
}
test size {Test of _stp_map_size()} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test size.c
} -body {
exec ./test
} -result {}
catch {exec rm test}
cleanupTests
|