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

Function TestFreelistHashmap_allocate

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

Source from the content-addressed store, hash-verified

21}
22
23func TestFreelistHashmap_allocate(t *testing.T) {
24 f := NewHashMapFreelist()
25
26 ids := []common.Pgid{3, 4, 5, 6, 7, 9, 12, 13, 18}
27 f.Init(ids)
28
29 f.Allocate(1, 3)
30 if x := f.FreeCount(); x != 6 {
31 t.Fatalf("exp=6; got=%v", x)
32 }
33
34 f.Allocate(1, 2)
35 if x := f.FreeCount(); x != 4 {
36 t.Fatalf("exp=4; got=%v", x)
37 }
38 f.Allocate(1, 1)
39 if x := f.FreeCount(); x != 3 {
40 t.Fatalf("exp=3; got=%v", x)
41 }
42
43 f.Allocate(1, 0)
44 if x := f.FreeCount(); x != 3 {
45 t.Fatalf("exp=3; got=%v", x)
46 }
47}
48
49func TestFreelistHashmap_mergeWithExist(t *testing.T) {
50 bm1 := pidSet{1: struct{}{}}

Callers

nothing calls this directly

Calls 5

NewHashMapFreelistFunction · 0.85
InitMethod · 0.65
AllocateMethod · 0.65
FreeCountMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected