3 test_description='test hashmap and string hash functions'
7 echo "$1" | test-hashmap $3 > actual &&
12 test_expect_success 'hash functions' '
14 test_hashmap "hash key1" "2215982743 2215982743 116372151 116372151" &&
15 test_hashmap "hash key2" "2215982740 2215982740 116372148 116372148" &&
16 test_hashmap "hash fooBarFrotz" "1383912807 1383912807 3189766727 3189766727" &&
17 test_hashmap "hash foobarfrotz" "2862305959 2862305959 3189766727 3189766727"
21 test_expect_success 'put' '
23 test_hashmap "put key1 value1
25 put fooBarFrotz value3
26 put foobarfrotz value4
35 test_expect_success 'put (case insensitive)' '
37 test_hashmap "put key1 value1
39 put fooBarFrotz value3
47 test_expect_success 'replace' '
49 test_hashmap "put key1 value1
51 put fooBarFrotz value3
52 put fooBarFrotz value4
61 test_expect_success 'replace (case insensitive)' '
63 test_hashmap "put key1 value1
65 put fooBarFrotz value3
66 put foobarfrotz value4
75 test_expect_success 'get' '
77 test_hashmap "put key1 value1
79 put fooBarFrotz value3
80 put foobarfrotz value4
95 test_expect_success 'get (case insensitive)' '
97 test_hashmap "put key1 value1
99 put fooBarFrotz value3
113 test_expect_success 'add' '
115 test_hashmap "add key1 value1
117 add fooBarFrotz value3
118 add fooBarFrotz value4
121 get notInMap" "value2
129 test_expect_success 'add (case insensitive)' '
131 test_hashmap "add key1 value1
133 add fooBarFrotz value3
134 add foobarfrotz value4
137 get notInMap" "value2
145 test_expect_success 'remove' '
147 test_hashmap "put key1 value1
149 put fooBarFrotz value3
163 test_expect_success 'remove (case insensitive)' '
165 test_hashmap "put key1 value1
167 put fooBarFrotz value3
181 test_expect_success 'iterate' '
183 test_hashmap "put key1 value1
185 put fooBarFrotz value3
195 test_expect_success 'iterate (case insensitive)' '
197 test_hashmap "put key1 value1
199 put fooBarFrotz value3
205 key1 value1" ignorecase
209 test_expect_success 'grow / shrink' '
213 for n in $(test_seq 51)
215 echo put key$n value$n >> in &&
219 echo 64 51 >> expect &&
220 echo put key52 value52 >> in &&
221 echo NULL >> expect &&
223 echo 256 52 >> expect &&
224 for n in $(test_seq 12)
226 echo remove key$n >> in &&
227 echo value$n >> expect
230 echo 256 40 >> expect &&
231 echo remove key40 >> in &&
232 echo value40 >> expect &&
234 echo 64 39 >> expect &&
235 cat in | test-hashmap > out &&
240 test_expect_success 'string interning' '
242 test_hashmap "intern value1