MCPcopy Index your code
hub / github.com/coder/hnsw / Test_binaryVarint

Function Test_binaryVarint

encode_test.go:11–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func Test_binaryVarint(t *testing.T) {
12 buf := bytes.NewBuffer(nil)
13 i := 1337
14
15 n, err := binaryWrite(buf, i)
16 require.NoError(t, err)
17 require.Equal(t, 2, n)
18
19 // Ensure that binaryRead doesn't read past the
20 // varint.
21 buf.Write([]byte{0, 0, 0, 0})
22
23 var j int
24 _, err = binaryRead(buf, &j)
25 require.NoError(t, err)
26 require.Equal(t, 1337, j)
27
28 require.Equal(
29 t,
30 []byte{0, 0, 0, 0},
31 buf.Bytes(),
32 )
33}
34
35func Test_binaryWrite_string(t *testing.T) {
36 buf := bytes.NewBuffer(nil)

Callers

nothing calls this directly

Calls 2

binaryWriteFunction · 0.85
binaryReadFunction · 0.85

Tested by

no test coverage detected