Bugfix: totalUnconsumedBytes works properly within withReadableRange blocks

This commit is contained in:
Zahary Karadjov 2020-05-29 16:08:14 +03:00
commit 81c24860e2
No known key found for this signature in database
GPG key ID: C8936F8A3073D609
2 changed files with 13 additions and 2 deletions

View file

@ -48,6 +48,9 @@ procSuite "input stream":
test "next returns none":
check input.next.isNone
emptyInputTests "memoryInput":
var input = InputStream()
emptyInputTests "unsafeMemoryInput":
var str = ""
var input = unsafeMemoryInput(str)
@ -140,12 +143,16 @@ procSuite "input stream":
let s = fileInput(asciiTableFile, pageSize = 100)
if s.readable(20):
s.withReadableRange(20, r):
check r.len.get == 20
check r.totalUnconsumedBytes == 20
check r.readAll.len == 20
check s.readable
if s.readable(200):
s.withReadableRange(200, r):
check r.len.get == 200
check r.totalUnconsumedBytes == 200
check r.readAll.len == 200
check s.readable