Add a test to xmlparser

This commit is contained in:
Matt Sullivan 2015-10-31 13:30:07 -05:00
commit 8671656e6f
2 changed files with 18 additions and 10 deletions

View file

@ -143,7 +143,8 @@ proc loadXml*(path: string): XmlNode =
result = loadXml(path, errors) result = loadXml(path, errors)
if errors.len > 0: raiseInvalidXml(errors) if errors.len > 0: raiseInvalidXml(errors)
when not defined(testing) and isMainModule: when isMainModule:
when not defined(testing):
import os import os
var errors: seq[string] = @[] var errors: seq[string] = @[]
@ -156,4 +157,10 @@ when not defined(testing) and isMainModule:
f.close() f.close()
else: else:
quit("cannot write test.txt") quit("cannot write test.txt")
else:
block: # correctly parse ../../tests/testdata/doc1.xml
let filePath = "tests/testdata/doc1.xml"
var errors: seq[string] = @[]
var xml = loadXml(filePath, errors)
assert(errors.len == 0, "The file tests/testdata/doc1.xml should be parsed without errors.")

View file

@ -5,6 +5,7 @@
<test2> <test2>
bla ah absy hsh bla ah absy hsh
hsh hsh
&woohoo;
sjj sjj
</test2> </test2>
<test><teh>bla</teh></test> <test><teh>bla</teh></test>