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

Function TestStreamDeserializationSlow

go/fory/stream_test.go:78–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

76}
77
78func TestStreamDeserializationSlow(t *testing.T) {
79 f := New(WithXlang(false), WithCompatible(false))
80 f.RegisterStruct(&StreamTestStruct{}, 100)
81
82 original := &StreamTestStruct{
83 ID: 42,
84 Name: "Slow Stream Test with a reasonably long string and some data to trigger multiple fills",
85 Data: bytes.Repeat([]byte{0xAA}, 100),
86 }
87
88 data, err := f.Serialize(original)
89 if err != nil {
90 t.Fatalf("Serialize failed: %v", err)
91 }
92
93 // Test with slow reader and small bufferSize to force compaction/growth
94 reader := &slowReader{data: data}
95 var decoded StreamTestStruct
96
97 // Create an InputStream with a small bufferSize (16) to force frequent fills and compactions
98 stream := NewInputStreamWithBufferSize(reader, 16)
99 err = f.DeserializeFromStream(stream, &decoded)
100 if err != nil {
101 t.Fatalf("DeserializeFromReader (slow) failed: %v", err)
102 }
103
104 if decoded.ID != original.ID || decoded.Name != original.Name || !bytes.Equal(decoded.Data, original.Data) {
105 t.Errorf("Decoded value mismatch (slow). Got: %+v, Want: %+v", decoded, original)
106 }
107}
108
109func TestStreamDeserializationEOF(t *testing.T) {
110 f := New(WithXlang(false), WithCompatible(false))

Callers

nothing calls this directly

Calls 8

WithXlangFunction · 0.85
WithCompatibleFunction · 0.85
DeserializeFromStreamMethod · 0.80
NewFunction · 0.70
RegisterStructMethod · 0.45
SerializeMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected