3 test_description='test hashmap and string hash functions'
7 echo "$1" | test-tool hashmap $3 > actual &&
12 test_expect_success 'put' '
14 test_hashmap "put key1 value1
16 put fooBarFrotz value3
17 put foobarfrotz value4
26 test_expect_success 'put (case insensitive)' '
28 test_hashmap "put key1 value1
30 put fooBarFrotz value3
38 test_expect_success 'replace' '
40 test_hashmap "put key1 value1
42 put fooBarFrotz value3
43 put fooBarFrotz value4
52 test_expect_success 'replace (case insensitive)' '
54 test_hashmap "put key1 value1
56 put fooBarFrotz value3
57 put foobarfrotz value4
66 test_expect_success 'get' '
68 test_hashmap "put key1 value1
70 put fooBarFrotz value3
71 put foobarfrotz value4
86 test_expect_success 'get (case insensitive)' '
88 test_hashmap "put key1 value1
90 put fooBarFrotz value3
104 test_expect_success 'add' '
106 test_hashmap "add key1 value1
108 add fooBarFrotz value3
109 add fooBarFrotz value4
112 get notInMap" "value2
120 test_expect_success 'add (case insensitive)' '
122 test_hashmap "add key1 value1
124 add fooBarFrotz value3
125 add foobarfrotz value4
128 get notInMap" "value2
136 test_expect_success 'remove' '
138 test_hashmap "put key1 value1
140 put fooBarFrotz value3
154 test_expect_success 'remove (case insensitive)' '
156 test_hashmap "put key1 value1
158 put fooBarFrotz value3
172 test_expect_success 'iterate' '
174 test_hashmap "put key1 value1
176 put fooBarFrotz value3
186 test_expect_success 'iterate (case insensitive)' '
188 test_hashmap "put key1 value1
190 put fooBarFrotz value3
196 key1 value1" ignorecase
200 test_expect_success 'grow / shrink' '
204 for n in $(test_seq 51)
206 echo put key$n value$n >> in &&
210 echo 64 51 >> expect &&
211 echo put key52 value52 >> in &&
212 echo NULL >> expect &&
214 echo 256 52 >> expect &&
215 for n in $(test_seq 12)
217 echo remove key$n >> in &&
218 echo value$n >> expect
221 echo 256 40 >> expect &&
222 echo remove key40 >> in &&
223 echo value40 >> expect &&
225 echo 64 39 >> expect &&
226 cat in | test-tool hashmap > out &&
231 test_expect_success 'string interning' '
233 test_hashmap "intern value1