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' '
173 test-tool hashmap >actual.raw <<-\EOF &&
176 put fooBarFrotz value3
180 cat >expect <<-\EOF &&
189 sort <actual.raw >actual &&
190 test_cmp expect actual
193 test_expect_success 'iterate (case insensitive)' '
194 test-tool hashmap ignorecase >actual.raw <<-\EOF &&
197 put fooBarFrotz value3
201 cat >expect <<-\EOF &&
210 sort <actual.raw >actual &&
211 test_cmp expect actual
214 test_expect_success 'grow / shrink' '
218 for n in $(test_seq 51)
220 echo put key$n value$n >> in &&
224 echo 64 51 >> expect &&
225 echo put key52 value52 >> in &&
226 echo NULL >> expect &&
228 echo 256 52 >> expect &&
229 for n in $(test_seq 12)
231 echo remove key$n >> in &&
232 echo value$n >> expect
235 echo 256 40 >> expect &&
236 echo remove key40 >> in &&
237 echo value40 >> expect &&
239 echo 64 39 >> expect &&
240 cat in | test-tool hashmap > out &&
245 test_expect_success 'string interning' '
247 test_hashmap "intern value1