svenvc / zinc

Zinc HTTP Components is an open-source Smalltalk framework to deal with the HTTP networking protocol.
MIT License
96 stars 56 forks source link

ZnBufferedReadStream>>back incorrectly flags an error that the stream is at the start #116

Closed akgrant43 closed 1 year ago

akgrant43 commented 1 year ago

ZnBufferedReadStream>>back incorrectly flags an error that the stream is at the start any time it is at the start of a buffer. The following test demonstrates the error:

testBack
    | stream source |

    "Allocate a buffer larger than the default size (65536)"
    self assert: ZnBufferedReadStream basicNew defaultBufferSize < 66000.
    source := ByteArray new: 70000.
    1 to: 70000 do: [ :i |
        source at: i put: i \\ 256 ].
    stream := ZnBufferedReadStream on: source readStream.
    stream position: 1.
    self assert: stream peek equals: (source at: 2).
    self assert: stream back equals: (source at: 1).
    "Position the stream beyond the end of the initial buffer"
    stream position: 66000.
    self assert: stream peek equals: (source at: 66001).
    self assert: stream back equals: (source at: 66000).

A PR with fix is on the way.