3 test_description
='test hashmap and string hash functions'
5 TEST_PASSES_SANITIZE_LEAK
=true
9 echo "$1" | test-tool hashmap
$3 > actual
&&
11 test_cmp expect actual
14 test_expect_success
'put' '
16 test_hashmap "put key1 value1
18 put fooBarFrotz value3
19 put foobarfrotz value4
28 test_expect_success
'put (case insensitive)' '
30 test_hashmap "put key1 value1
32 put fooBarFrotz value3
40 test_expect_success
'replace' '
42 test_hashmap "put key1 value1
44 put fooBarFrotz value3
45 put fooBarFrotz value4
54 test_expect_success
'replace (case insensitive)' '
56 test_hashmap "put key1 value1
58 put fooBarFrotz value3
59 put foobarfrotz value4
68 test_expect_success
'get' '
70 test_hashmap "put key1 value1
72 put fooBarFrotz value3
73 put foobarfrotz value4
88 test_expect_success
'get (case insensitive)' '
90 test_hashmap "put key1 value1
92 put fooBarFrotz value3
106 test_expect_success
'add' '
108 test_hashmap "add key1 value1
110 add fooBarFrotz value3
111 add fooBarFrotz value4
114 get notInMap" "value2
122 test_expect_success
'add (case insensitive)' '
124 test_hashmap "add key1 value1
126 add fooBarFrotz value3
127 add foobarfrotz value4
130 get notInMap" "value2
138 test_expect_success
'remove' '
140 test_hashmap "put key1 value1
142 put fooBarFrotz value3
156 test_expect_success
'remove (case insensitive)' '
158 test_hashmap "put key1 value1
160 put fooBarFrotz value3
174 test_expect_success
'iterate' '
175 test-tool hashmap >actual.raw <<-\EOF &&
178 put fooBarFrotz value3
182 cat >expect <<-\EOF &&
191 sort <actual.raw >actual &&
192 test_cmp expect actual
195 test_expect_success
'iterate (case insensitive)' '
196 test-tool hashmap ignorecase >actual.raw <<-\EOF &&
199 put fooBarFrotz value3
203 cat >expect <<-\EOF &&
212 sort <actual.raw >actual &&
213 test_cmp expect actual
216 test_expect_success
'grow / shrink' '
220 for n in $(test_seq 51)
222 echo put key$n value$n >> in &&
223 echo NULL >> expect || return 1
226 echo 64 51 >> expect &&
227 echo put key52 value52 >> in &&
228 echo NULL >> expect &&
230 echo 256 52 >> expect &&
231 for n in $(test_seq 12)
233 echo remove key$n >> in &&
234 echo value$n >> expect || return 1
237 echo 256 40 >> expect &&
238 echo remove key40 >> in &&
239 echo value40 >> expect &&
241 echo 64 39 >> expect &&
242 test-tool hashmap <in >out &&
247 test_expect_success
'string interning' '
249 test_hashmap "intern value1