MCPcopy Create free account
hub / github.com/segmentio/encoding / TestEncodeDecodeVarint

Function TestEncodeDecodeVarint

proto/proto_test.go:12–30  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestEncodeDecodeVarint(t *testing.T) {
13 b := [8]byte{}
14
15 n, err := encodeVarint(b[:], 42)
16 if err != nil {
17 t.Fatal(err)
18 }
19
20 v, n2, err := decodeVarint(b[:n])
21 if err != nil {
22 t.Fatal(err)
23 }
24 if v != 42 {
25 t.Errorf("decoded value mismatch: want %d, got %d", 42, v)
26 }
27 if n2 != n {
28 t.Errorf("decoded byte count mismatch: want %d, got %d", n, n2)
29 }
30}
31
32func TestEncodeDecodeVarintZigZag(t *testing.T) {
33 b := [8]byte{}

Callers

nothing calls this directly

Calls 2

encodeVarintFunction · 0.85
decodeVarintFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…