MCPcopy Create free account
hub / github.com/chain/Core / TestReadWriteVarint31

Function TestReadWriteVarint31

encoding/blockchain/blockchain_test.go:317–330  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

315}
316
317func TestReadWriteVarint31(t *testing.T) {
318 f := func(x uint32) bool {
319 var buf bytes.Buffer
320 _, err := WriteVarint31(&buf, uint64(x))
321 if err == ErrRange {
322 return x > math.MaxInt32
323 }
324 v, err := ReadVarint31(NewReader(buf.Bytes()))
325 return uint32(v) == x && err == nil
326 }
327 if err := quick.Check(f, nil); err != nil {
328 t.Error(err)
329 }
330}
331
332func TestReadWriteVarint63(t *testing.T) {
333 f := func(x uint64) bool {

Callers

nothing calls this directly

Calls 6

WriteVarint31Function · 0.85
ReadVarint31Function · 0.85
NewReaderFunction · 0.85
CheckMethod · 0.80
BytesMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected