MCPcopy
hub / github.com/segmentio/kafka-go / TestReadMapStringInt32

Function TestReadMapStringInt32

read_test.go:85–117  ·  read_test.go::TestReadMapStringInt32
(t *testing.T)

Source from the content-addressed store, hash-verified

83}
84
85func TestReadMapStringInt32(t *testing.T) {
86 testCases := map[string]struct {
87 Data map[string][]int32
88 }{
89 "empty": {
90 Data: map[string][]int32{},
91 },
92 "single element": {
93 Data: map[string][]int32{
94 "key": {0, 1, 2},
95 },
96 },
97 }
98
99 for label, test := range testCases {
100 t.Run(label, func(t *testing.T) {
101 b := bytes.NewBuffer(nil)
102 w := &writeBuffer{w: b}
103 w.writeInt32(int32(len(test.Data)))
104
105 for key, values := range test.Data {
106 w.writeString(key)
107 w.writeInt32Array(values)
108 }
109
110 var actual map[string][]int32
111 readMapStringInt32(bufio.NewReader(b), b.Len(), &actual)
112 if !reflect.DeepEqual(test.Data, actual) {
113 t.Errorf("expected %#v; got %#v", test.Data, actual)
114 }
115 })
116 }
117}
118
119func TestReadNewBytes(t *testing.T) {
120

Callers

nothing calls this directly

Calls 6

writeInt32Method · 0.95
writeStringMethod · 0.95
writeInt32ArrayMethod · 0.95
readMapStringInt32Function · 0.85
NewReaderMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected