MCPcopy Create free account
hub / github.com/HDT3213/rdb / TestLengthEncoding

Function TestLengthEncoding

core/string_test.go:12–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestLengthEncoding(t *testing.T) {
13 buf := bytes.NewBuffer(nil)
14 enc := NewEncoder(buf)
15 lens := []uint64{1 << 5, 1 << 13, 1 << 31, 1 << 63}
16 for _, v := range lens {
17 err := enc.writeLength(v)
18 if err != nil {
19 t.Error(err)
20 return
21 }
22 }
23 dec := NewDecoder(buf)
24 for _, expect := range lens {
25 actual, special, err := dec.readLength()
26 if err != nil {
27 t.Error(err)
28 return
29 }
30 if special {
31 t.Error("expect normal actual special")
32 return
33 }
34 if actual != expect {
35 t.Errorf("expect %d, actual %d", expect, actual)
36 }
37 }
38}
39
40func TestStringEncoding(t *testing.T) {
41 buf := bytes.NewBuffer(nil)

Callers

nothing calls this directly

Calls 4

writeLengthMethod · 0.95
readLengthMethod · 0.95
NewEncoderFunction · 0.85
NewDecoderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…