MCPcopy
hub / github.com/syncthing/syncthing / TestGetBucketNumbers

Function TestGetBucketNumbers

lib/protocol/bufferpool_test.go:17–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestGetBucketNumbers(t *testing.T) {
18 cases := []struct {
19 size int
20 bkt int
21 panics bool
22 }{
23 {size: 1024, bkt: 0},
24 {size: MinBlockSize, bkt: 0},
25 {size: MinBlockSize + 1, bkt: 1},
26 {size: 2*MinBlockSize - 1, bkt: 1},
27 {size: 2 * MinBlockSize, bkt: 1},
28 {size: 2*MinBlockSize + 1, bkt: 2},
29 {size: MaxBlockSize, bkt: len(BlockSizes) - 1},
30 {size: MaxBlockSize + 1, panics: true},
31 }
32
33 for _, tc := range cases {
34 if tc.panics {
35 shouldPanic(t, func() { getBucketForLen(tc.size) })
36 } else {
37 res := getBucketForLen(tc.size)
38 if res != tc.bkt {
39 t.Errorf("block of size %d should get from bucket %d, not %d", tc.size, tc.bkt, res)
40 }
41 }
42 }
43}
44
45func TestPutBucketNumbers(t *testing.T) {
46 cases := []struct {

Callers

nothing calls this directly

Calls 2

shouldPanicFunction · 0.85
getBucketForLenFunction · 0.85

Tested by

no test coverage detected