MCPcopy
hub / github.com/etcd-io/bbolt / TestFreelistHashmap_GetFreePageIDs

Function TestFreelistHashmap_GetFreePageIDs

internal/freelist/hashmap_test.go:144–164  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

142}
143
144func TestFreelistHashmap_GetFreePageIDs(t *testing.T) {
145 f := newTestHashMapFreelist()
146
147 N := int32(100000)
148 fm := make(map[common.Pgid]uint64)
149 i := int32(0)
150 val := int32(0)
151 for i = 0; i < N; {
152 val = rand.Int31n(1000)
153 fm[common.Pgid(i)] = uint64(val)
154 i += val
155 f.freePagesCount += uint64(val)
156 }
157
158 f.forwardMap = fm
159 res := f.freePageIds()
160
161 if !sort.SliceIsSorted(res, func(i, j int) bool { return res[i] < res[j] }) {
162 t.Fatalf("pgids not sorted")
163 }
164}
165
166func Test_Freelist_Hashmap_Rollback(t *testing.T) {
167 f := newTestHashMapFreelist()

Callers

nothing calls this directly

Calls 4

PgidTypeAlias · 0.92
newTestHashMapFreelistFunction · 0.85
freePageIdsMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected