(t *testing.T)
| 76 | } |
| 77 | |
| 78 | func 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 | |
| 109 | func TestStreamDeserializationEOF(t *testing.T) { |
| 110 | f := New(WithXlang(false), WithCompatible(false)) |
nothing calls this directly
no test coverage detected