mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-17 00:24:16 +00:00
Add unit tests
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user