diff options
| author | 2026-03-06 16:23:26 +0800 | |
|---|---|---|
| committer | 2026-03-06 16:23:26 +0800 | |
| commit | e808bdaa15b4df61d9575192fc34cde77890da1c (patch) | |
| tree | 5ca37ced633e43d5228cb0fa62520f1c6a2ca631 /format/sideband64k/helpers_test.go | |
| parent | ci: Add go-fix (diff) | |
| signature | No signature | |
format/sideband64k: Add side-band-64k v0.1.66
Diffstat (limited to 'format/sideband64k/helpers_test.go')
| -rw-r--r-- | format/sideband64k/helpers_test.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/format/sideband64k/helpers_test.go b/format/sideband64k/helpers_test.go new file mode 100644 index 00000000..c10e9e71 --- /dev/null +++ b/format/sideband64k/helpers_test.go @@ -0,0 +1,44 @@ +package sideband64k_test + +import ( + "bytes" + "io" +) + +type limitWriter struct { + buf bytes.Buffer + maxPerWrite int + flushes int + shortWrite bool +} + +func (w *limitWriter) Write(p []byte) (int, error) { + if w.shortWrite { + return 0, nil + } + + if w.maxPerWrite > 0 && len(p) > w.maxPerWrite { + p = p[:w.maxPerWrite] + } + + return w.buf.Write(p) +} + +func (w *limitWriter) Flush() error { + w.flushes++ + return nil +} + +type byteReader struct { + data []byte +} + +func (r *byteReader) Read(p []byte) (int, error) { + if len(r.data) == 0 { + return 0, io.EOF + } + + p[0] = r.data[0] + r.data = r.data[1:] + return 1, nil +} |
