fix memFileInput.pos return negative value (#16)

This commit is contained in:
andri lim 2021-02-18 22:56:17 +07:00 • committed by GitHub
commit 367cb55eef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -164,3 +164,21 @@ procSuite "input stream":
check:
(stream.read(4) == "1234".toOpenArrayByte(0, 3))
template posTest(name: string, setup: untyped) =
test name:
setup
check input.readable
check input.pos == 0
discard input.read
check input.pos == 1
close input
posTest "unsafeMemoryInput pos":
var str = "hello"
var input = unsafeMemoryInput(str)
posTest "fileInput pos":
var input = fileInput(asciiTableFile)
posTest "memFileInput pos":
var input = memFileInput(asciiTableFile)