summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/find.nim4
-rw-r--r--test/replace.nim8
-rw-r--r--test/testall.nim1
3 files changed, 13 insertions, 0 deletions
diff --git a/test/find.nim b/test/find.nim
index 6ea4f51e8..1fd91f0d2 100644
--- a/test/find.nim
+++ b/test/find.nim
@@ -16,3 +16,7 @@ suite "find":
   test "overlapping find":
     check("222".findAllStr(re"22") == @["22"])
     check("2222".findAllStr(re"22") == @["22", "22"])
+
+  test "len 0 find":
+    check("".findAllStr(re"\ ") == newSeq[string]())
+    check("".findAllStr(re"") == @[""])
diff --git a/test/replace.nim b/test/replace.nim
new file mode 100644
index 000000000..df7227f0b
--- /dev/null
+++ b/test/replace.nim
@@ -0,0 +1,8 @@
+include nre
+import unittest
+
+suite "replace":
+  test "replace with 0-length strings":
+    check("".replace(re"1", proc (v: RegexMatch): string = "1") == "")
+    check(" ".replace(re"", proc (v: RegexMatch): string = "1") == "1 ")
+    check("".replace(re"", proc (v: RegexMatch): string = "1") == "1")
diff --git a/test/testall.nim b/test/testall.nim
index 6fa3e9bca..89b661a2a 100644
--- a/test/testall.nim
+++ b/test/testall.nim
@@ -4,3 +4,4 @@ import captures
 import find
 import split
 import match
+import replace