Implement the full behavior of withReadableRange; close #12

This commit is contained in:
Zahary Karadjov 2020-05-22 09:44:25 +03:00
commit 442ad53b00
No known key found for this signature in database
GPG key ID: C8936F8A3073D609
4 changed files with 160 additions and 121 deletions

View file

@ -53,10 +53,10 @@ procSuite "input stream":
var input = unsafeMemoryInput(str)
emptyInputTests "fileInput":
var input = memFileInput("files" / "empty_file")
var input = fileInput("files" / "empty_file")
emptyInputTests "memFileInput":
var input = fileInput("files" / "empty_file")
var input = memFileInput("files" / "empty_file")
template asciiTableFileTest(name: string, body: untyped) =
test name & " of ascii table with regular pageSize":
@ -137,11 +137,18 @@ procSuite "input stream":
check not fileExists(fileName)
test "non-blocking reads":
let s = fileInput(asciiTableFile, pageSize = 20)
if s.readable:
let s = fileInput(asciiTableFile, pageSize = 100)
if s.readable(20):
s.withReadableRange(20, r):
check r.readAll.len == 20
check s.readable
check s.readable
if s.readable(200):
s.withReadableRange(200, r):
check r.readAll.len == 200
check s.readable
test "simple":
var input = repeat("1234 5678 90AB CDEF\n", 1000)