Remove findAll, rename findAllStr to findAll
This commit is contained in:
parent
6bd3660238
commit
a5693675fb
1 changed files with 9 additions and 14 deletions
|
|
@ -1,22 +1,21 @@
|
|||
import unittest
|
||||
include nre
|
||||
import unittest, sequtils, nre
|
||||
|
||||
suite "find":
|
||||
test "find text":
|
||||
check("3213a".find(re"[a-z]").match == "a")
|
||||
check("1 2 3 4 5 6 7 8 ".findAll(re" ").map(
|
||||
check(toSeq(findIter("1 2 3 4 5 6 7 8 ", re" ")).map(
|
||||
proc (a: RegexMatch): string = a.match
|
||||
) == @[" ", " ", " ", " ", " ", " ", " ", " "])
|
||||
|
||||
test "find bounds":
|
||||
check("1 2 3 4 5 ".findAll(re" ").map(
|
||||
check(toSeq(findIter("1 2 3 4 5 ", re" ")).map(
|
||||
proc (a: RegexMatch): Slice[int] = a.matchBounds
|
||||
) == @[1..2, 3..4, 5..6, 7..8, 9..10])
|
||||
|
||||
test "overlapping find":
|
||||
check("222".findAllStr(re"22") == @["22"])
|
||||
check("2222".findAllStr(re"22") == @["22", "22"])
|
||||
check("222".findAll(re"22") == @["22"])
|
||||
check("2222".findAll(re"22") == @["22", "22"])
|
||||
|
||||
test "len 0 find":
|
||||
check("".findAllStr(re"\ ") == newSeq[string]())
|
||||
check("".findAllStr(re"") == @[""])
|
||||
check("".findAll(re"\ ") == newSeq[string]())
|
||||
check("".findAll(re"") == @[""])
|
||||
|
|
|
|||
Loading…
Reference in a new issue