Add unit tests
This commit is contained in:
parent
dec2f9efa9
commit
685e4a1f0b
2 changed files with 27 additions and 0 deletions
26
test/init.nim
Normal file
26
test/init.nim
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import unittest
|
||||
include nre
|
||||
|
||||
suite "Test NRE initialization":
|
||||
test "correct intialization":
|
||||
check(initRegex("[0-9]+") != nil)
|
||||
check(initRegex("[0-9]+", "iS") != nil)
|
||||
|
||||
test "correct options":
|
||||
expect(SyntaxError): # ValueError would be bad
|
||||
discard initRegex("[0-9]+",
|
||||
"89?AEfiJmNOsUWXxY<any><anycrlf><cr><crlf><lf><bsr_anycrlf><bsr_unicode><js>")
|
||||
|
||||
test "incorrect options":
|
||||
expect(KeyError): discard initRegex("[0-9]+", "a")
|
||||
expect(KeyError): discard initRegex("[0-9]+", "<does_not_exist>")
|
||||
|
||||
test "invalid regex":
|
||||
expect(SyntaxError): discard initRegex("[0-9")
|
||||
try:
|
||||
discard initRegex("[0-9")
|
||||
except SyntaxError:
|
||||
let ex = SyntaxError(getCurrentException())
|
||||
check(ex.pos == 4)
|
||||
check(ex.pattern == "[0-9")
|
||||
|
||||
1
test/testall.nim
Normal file
1
test/testall.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
include init
|
||||
Loading…
Add table
Add a link
Reference in a new issue