You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just in case there is interest, here are two other badly-behaved reader types that might make useful additions to testing/iotest:
// ZeroNilReader returns 0, nil on every second read. Other calls to read succeed.funcZeroNilReader(r io.Reader) io.Reader// CorruptingReader returns a Reader that modifies any unused portion of the byte slice passed to Read.// It is useful in conjunction with OneByteReader.funcCorruptingReader(r io.Reader) io.Reader
The text was updated successfully, but these errors were encountered:
I am not sure, the CorruptingReader is still within the contract of an io.Reader. It appears quite common to pass the lower and the upper half of a buffer represented by a byte slice to two different Read() calls in order to save the copying.
Could you provide a usage sample demonstrating what kind of error/good behavior that would expose?
From the io.Reader docs: "Even if Read returns n < len(p), it may use all of p as scratch space during the call." The CorruptingReader would be checking that the caller doesn't rely on Read leaving the buffer untouched aside from the part containing newly read data.
Just in case there is interest, here are two other badly-behaved reader types that might make useful additions to
testing/iotest
:The text was updated successfully, but these errors were encountered: