Add tests
This commit is contained in:
4
tests/config.nims
Normal file
4
tests/config.nims
Normal file
@@ -0,0 +1,4 @@
|
||||
switch("define", "nimUnittestOutputLevel:PRINT_FAILURES")
|
||||
switch("warnings", false)
|
||||
switch("hints", false)
|
||||
switch("path", "$projectDir/../src")
|
||||
1
tests/nim.cfg
Normal file
1
tests/nim.cfg
Normal file
@@ -0,0 +1 @@
|
||||
--path: "../src/"
|
||||
22
tests/utils/test_str.nim
Normal file
22
tests/utils/test_str.nim
Normal file
@@ -0,0 +1,22 @@
|
||||
import std/unittest
|
||||
import utils/str
|
||||
|
||||
suite "utils/str":
|
||||
test "safeDelete":
|
||||
let t = "abc"
|
||||
check(t.safeDelete(0..0) == "abc")
|
||||
|
||||
check(t.safeDelete(0..1) == "c")
|
||||
check(t.safeDelete(1..1) == "ac")
|
||||
check(t.safeDelete(2..2) == "ab")
|
||||
|
||||
# Out of bounds slicing
|
||||
check(t.safeDelete(0..10) == "")
|
||||
check(t.safeDelete(10..1) == t)
|
||||
check(t.safeDelete(3..3) == t)
|
||||
check(t.safeDelete(3..(-1)) == t)
|
||||
|
||||
test "findAndDelete":
|
||||
let t = "foo\nbar"
|
||||
check(t.deleteAfterNewline() == "foo")
|
||||
check(t.deleteAfterNewline(start = 4) == t)
|
||||
Reference in New Issue
Block a user