mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 19:02:18 +00:00
Add a test case with 0-length match
Thanks Oleh Prypin
This commit is contained in:
@@ -4,10 +4,14 @@ suite "match":
|
||||
test "upper bound must be exclusive":
|
||||
check("abc".match(re"abc", endpos = 0) == nil)
|
||||
check("abc".match(re"abc", endpos = 3) != nil)
|
||||
test "examples":
|
||||
|
||||
test "match examples":
|
||||
check("abc".match(re"(\w)").captures[0] == "a")
|
||||
check("abc".match(re"(?<letter>\w)").captures["letter"] == "a")
|
||||
check("abc".match(re"(\w)\w").captures[-1] == "ab")
|
||||
check("abc".match(re"(\w)").captureBounds[0].get == 0..1)
|
||||
check("abc".match(re"").captureBounds[-1].get == 0..0)
|
||||
check("abc".match(re"abc").captureBounds[-1].get == 0..3)
|
||||
|
||||
test "match test cases":
|
||||
check("123".match(re"").matchBounds == 0..0)
|
||||
|
||||
Reference in New Issue
Block a user