MCPcopy Create free account
hub / github.com/IBM/sarama / TestRealDecoderGetNullableInt32Array

Function TestRealDecoderGetNullableInt32Array

real_decoder_test.go:85–131  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

83}
84
85func TestRealDecoderGetNullableInt32Array(t *testing.T) {
86 tests := []struct {
87 name string
88 input []byte
89 want []int32
90 wantErr error
91 }{
92 {
93 name: "null array",
94 input: []byte{0xFF, 0xFF, 0xFF, 0xFF},
95 },
96 {
97 name: "empty array",
98 input: []byte{0x00, 0x00, 0x00, 0x00},
99 want: []int32{},
100 },
101 {
102 name: "valid array",
103 input: []byte{0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02},
104 want: []int32{1, 2},
105 },
106 {
107 name: "insufficient data for length",
108 input: []byte{0x00, 0x00, 0x00},
109 wantErr: ErrInsufficientData,
110 },
111 {
112 name: "insufficient data for elements",
113 input: []byte{0x00, 0x00, 0x00, 0x02},
114 wantErr: ErrInsufficientData,
115 },
116 {
117 name: "invalid length",
118 input: []byte{0x80, 0x00, 0x00, 0x00},
119 wantErr: errInvalidArrayLength,
120 },
121 }
122
123 for _, tt := range tests {
124 t.Run(tt.name, func(t *testing.T) {
125 rd := &realDecoder{raw: tt.input}
126 got, err := rd.getNullableInt32Array()
127 require.ErrorIs(t, err, tt.wantErr)
128 assert.Equal(t, tt.want, got)
129 })
130 }
131}
132
133// getInt32Array only diverges from getNullableInt32Array on null input
134func TestRealDecoderGetInt32Array(t *testing.T) {

Callers

nothing calls this directly

Calls 2

getNullableInt32ArrayMethod · 0.95
RunMethod · 0.80

Tested by

no test coverage detected