WIP lexer unit tests.

This commit is contained in:
2023-04-01 17:36:01 -05:00
parent 2bc5d5c74f
commit c322616747
4 changed files with 18 additions and 13 deletions

View File

@ -1,4 +1,4 @@
import std/[streams, unicode]
import std/[streams, unicode, unittest]
type VCardLexer* = object of RootObj
input: Stream
@ -145,3 +145,17 @@ proc peekRune*(vcl: var VCardLexer): Rune =
proc getColNumber*(vcl: VCardLexer, pos: int): int =
if vcl.lineStart < pos: return pos - vcl.lineStart
else: return (vcl.buffer.len - vcl.lineStart) + pos
suite "vcard/lexer":
func expectBfr(l: VCardLexer, s: string): bool =
for i in 0..<s.len:
if s[i] != l.buffer[i]:
return false
return true
test "can open and fill buffer":
var l: VCardLexer
l.open(newStringStream("test"))
check l.expectBfr("test")