Skip to content

Commit fa48a55

Browse files
committed
Extract func to check map + use for empty test
1 parent 99e4718 commit fa48a55

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

uint32_store_test.go

+6-11
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,17 @@ import (
1414
)
1515

1616
func TestFastStringToUint32Empty(t *testing.T) {
17-
ms := mapSliceN(nil, 0)
18-
fm := faststringmap.NewUint32Store(ms)
19-
if keys := ms.AppendKeys(nil); len(keys) != 0 {
20-
t.Errorf("keys should be empty, got %#v", keys)
21-
}
22-
for _, k := range []string{"", "a", "foo", "ß"} {
23-
if actV, ok := fm.LookupString(k); ok {
24-
t.Errorf("%q present when not expected, got %d", k, actV)
25-
}
26-
}
17+
ms := mapSliceN(map[string]uint32{"": 1, "a": 2, "foo": 3, "ß": 4}, 0)
18+
checkWithMapSlice(t, ms)
2719
}
2820

2921
func TestFastStringToUint32(t *testing.T) {
3022
const nStrs = 8192
3123
m := randomSmallStrings(nStrs, 8)
32-
ms := mapSliceN(m, len(m)/2)
24+
checkWithMapSlice(t, mapSliceN(m, len(m)/2))
25+
}
26+
27+
func checkWithMapSlice(t *testing.T, ms mapSlice) {
3328
fm := faststringmap.NewUint32Store(ms)
3429

3530
for _, k := range ms.in {

0 commit comments

Comments
 (0)