fix memFileInput.pos return negative value (#16)
This commit is contained in:
parent
9138f6a8bb
commit
367cb55eef
2 changed files with 19 additions and 0 deletions
|
|
@ -205,6 +205,7 @@ proc memFileInput*(filename: string, mappedSize = -1, offset = 0): InputStreamHa
|
|||
span: PageSpan(
|
||||
startAddr: head,
|
||||
endAddr: offset(head, mappedSize)),
|
||||
spanEndPos: mappedSize,
|
||||
file: memFile)
|
||||
except OSError as err:
|
||||
raise newException(IOError, err.msg, err)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue