(t *testing.T)
| 199 | } |
| 200 | |
| 201 | func TestRealFlexibleDecoderGetNullableInt64Array(t *testing.T) { |
| 202 | tests := []struct { |
| 203 | name string |
| 204 | input []byte |
| 205 | want []int64 |
| 206 | wantErr error |
| 207 | }{ |
| 208 | { |
| 209 | name: "null array", |
| 210 | input: []byte{0x00}, |
| 211 | }, |
| 212 | { |
| 213 | name: "empty array", |
| 214 | input: []byte{0x01}, |
| 215 | want: []int64{}, |
| 216 | }, |
| 217 | { |
| 218 | name: "valid array", |
| 219 | input: []byte{ |
| 220 | 0x03, |
| 221 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, |
| 222 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, |
| 223 | }, |
| 224 | want: []int64{1, 2}, |
| 225 | }, |
| 226 | { |
| 227 | name: "insufficient data", |
| 228 | input: []byte{0x03}, |
| 229 | wantErr: ErrInsufficientData, |
| 230 | }, |
| 231 | } |
| 232 | |
| 233 | for _, tt := range tests { |
| 234 | t.Run(tt.name, func(t *testing.T) { |
| 235 | rd := &realFlexibleDecoder{&realDecoder{raw: tt.input}} |
| 236 | got, err := rd.getNullableInt64Array() |
| 237 | require.ErrorIs(t, err, tt.wantErr) |
| 238 | assert.Equal(t, tt.want, got) |
| 239 | }) |
| 240 | } |
| 241 | t.Run("returns insufficient data for compact length exceeding int64", func(t *testing.T) { |
| 242 | var input [binary.MaxVarintLen64]byte |
| 243 | n := binary.PutUvarint(input[:], 1<<63) |
| 244 | |
| 245 | rd := &realFlexibleDecoder{&realDecoder{raw: input[:n]}} |
| 246 | array, err := rd.getNullableInt64Array() |
| 247 | |
| 248 | require.ErrorIs(t, err, ErrInsufficientData) |
| 249 | assert.Nil(t, array) |
| 250 | }) |
| 251 | } |
| 252 | |
| 253 | // getInt64Array only diverges from getNullableInt64Array on null input |
| 254 | func TestRealFlexibleDecoderGetInt64Array(t *testing.T) { |
nothing calls this directly
no test coverage detected