MCPcopy Index your code
hub / github.com/HDT3213/rdb / TestStringEncoding

Function TestStringEncoding

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

Source from the content-addressed store, hash-verified

38}
39
40func TestStringEncoding(t *testing.T) {
41 buf := bytes.NewBuffer(nil)
42 enc := NewEncoder(buf)
43 strList := []string{
44 "",
45 "abc",
46 "12",
47 "32766",
48 "007",
49 "0",
50 "+0",
51 "-0",
52 "+1",
53 "-1",
54 "0x11",
55 "0o00",
56 strconv.Itoa(math.MaxInt8),
57 strconv.Itoa(math.MinInt8),
58 strconv.Itoa(math.MaxInt16),
59 strconv.Itoa(math.MinInt16),
60 strconv.Itoa(math.MaxInt32),
61 strconv.Itoa(math.MaxInt32) + "1",
62 strconv.Itoa(math.MinInt32),
63 strconv.Itoa(math.MinInt32) + "1",
64 strconv.Itoa(math.MaxInt64),
65 strconv.Itoa(math.MaxInt64) + "1",
66 strconv.Itoa(math.MinInt64),
67 strconv.Itoa(math.MinInt64) + "1",
68 RandString(20000),
69 }
70 for _, str := range strList {
71 err := enc.writeString(str)
72 if err != nil {
73 t.Error(err)
74 return
75 }
76 }
77 dec := NewDecoder(buf)
78 for _, expect := range strList {
79 actual, err := dec.readString()
80 if err != nil {
81 t.Error(err)
82 continue
83 }
84 if string(actual) != expect {
85 t.Errorf("expect %s, actual %s", expect, string(actual))
86 }
87 }
88}
89
90func TestRandomStringEncoding(t *testing.T) {
91 size := 1000

Callers

nothing calls this directly

Calls 5

writeStringMethod · 0.95
readStringMethod · 0.95
NewEncoderFunction · 0.85
NewDecoderFunction · 0.85
RandStringFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…