MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / TestBlockInfo

Function TestBlockInfo

cmd/cql-fuse/block_test.go:314–334  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

312}
313
314func TestBlockInfo(t *testing.T) {
315 testCases := []struct {
316 start, length uint64
317 expected blockRange
318 }{
319 {0, 0, blockRange{0, 0, 0, 0, 0}},
320 {0, BlockSize * 4, blockRange{0, 0, BlockSize, 4, 0}},
321 {0, BlockSize*4 + 500, blockRange{0, 0, BlockSize, 4, 500}},
322 {500, BlockSize * 4, blockRange{0, 500, BlockSize - 500, 4, 500}},
323 {BlockSize, BlockSize * 4, blockRange{1, 0, BlockSize, 5, 0}},
324 {BlockSize, 500, blockRange{1, 0, 500, 1, 500}},
325 {500, 1000, blockRange{0, 500, 1000, 0, 1500}},
326 }
327
328 for tcNum, tc := range testCases {
329 actual := newBlockRange(tc.start, tc.length)
330 if !reflect.DeepEqual(actual, tc.expected) {
331 t.Errorf("#%d: expected:\n%+v\ngot:\n%+v", tcNum, tc.expected, actual)
332 }
333 }
334}
335
336func tryGrow(db *sql.DB, data []byte, id, newSize uint64) ([]byte, error) {
337 originalSize := uint64(len(data))

Callers

nothing calls this directly

Calls 2

newBlockRangeFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected