MCPcopy Create free account
hub / github.com/cantabular/faststringmap / checkWithMapSlice

Function checkWithMapSlice

uint32_store_test.go:32–56  ·  view source on GitHub ↗
(t *testing.T, ms mapSlice)

Source from the content-addressed store, hash-verified

30}
31
32func checkWithMapSlice(t *testing.T, ms mapSlice) {
33 fm := faststringmap.NewUint32Store(ms)
34
35 for _, k := range ms.in {
36 check := func(actV uint32, ok bool) {
37 if !ok {
38 t.Errorf("%q not present", k)
39 } else if actV != ms.m[k] {
40 t.Errorf("got %d want %d for %q", actV, ms.m[k], k)
41 }
42 }
43 check(fm.LookupString(k))
44 check(fm.LookupBytes([]byte(k)))
45 }
46
47 for _, k := range ms.out {
48 check := func(actV uint32, ok bool) {
49 if ok {
50 t.Errorf("%q present when not expected, got %d", k, actV)
51 }
52 }
53 check(fm.LookupString(k))
54 check(fm.LookupBytes([]byte(k)))
55 }
56}
57
58type mapSlice struct {
59 m map[string]uint32

Callers 3

TestFastStringToUint32Function · 0.85

Calls 3

LookupStringMethod · 0.95
LookupBytesMethod · 0.95
NewUint32StoreFunction · 0.92

Tested by

no test coverage detected