MCPcopy Create free account
hub / github.com/apache/fory / TestReadInt32Slice_OOM_Bug

Function TestReadInt32Slice_OOM_Bug

go/fory/slice_primitive_test.go:464–477  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

462}
463
464func TestReadInt32Slice_OOM_Bug(t *testing.T) {
465 // We claim a size of 40,000 bytes, but provide no actual data.
466 buf := NewByteBuffer(nil)
467 buf.WriteLength(40000)
468
469 // Reset reader index so we can read what we just wrote
470 buf.SetReaderIndex(0)
471
472 err := &Error{}
473 result := ReadInt32Slice(buf, err)
474
475 assert.True(t, err.HasError(), "Expected an error due to out of bounds buffer")
476 assert.Equal(t, 0, len(result), "Expected an empty slice due to missing data")
477}
478
479func TestReadFixedWidthSliceBytes(t *testing.T) {
480 t.Run("unaligned_size", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

WriteLengthMethod · 0.95
SetReaderIndexMethod · 0.95
HasErrorMethod · 0.95
NewByteBufferFunction · 0.85
ReadInt32SliceFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected