Fix skipping an empty match at the end

This commit is contained in:
Oleh Prypin 2015-04-12 15:18:16 +03:00
commit 02c6e7306f
2 changed files with 5 additions and 4 deletions

View file

@ -19,6 +19,7 @@ suite "find":
test "len 0 find":
check("".findAll(re"\ ") == newSeq[string]())
check("".findAll(re"") == @[""])
check("abc".findAll(re"") == @["", "", "", ""])
check("word word".findAll(re"\b") == @["", "", "", ""])
check("word\r\lword".findAll(re(r"$", "m<anycrlf>")) == @["", ""])
check("слово слово".findAll(re(r"\b", "uW")) == @["", "", "", ""])

View file

@ -4,7 +4,7 @@ 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 1")
check("".replace(re"", proc (v: RegexMatch): string = "1") == "1")
test "regular replace":