From a7ce05b42fca227eb28e06a100219e2f07df6098 Mon Sep 17 00:00:00 2001 From: Flaviu Tamas Date: Fri, 16 Jan 2015 20:04:38 -0500 Subject: [PATCH] Add tests for claims in documentation --- test/find.nim | 4 ++++ test/split.nim | 3 +++ 2 files changed, 7 insertions(+) diff --git a/test/find.nim b/test/find.nim index 87f8e0aae9..6ea4f51e87 100644 --- a/test/find.nim +++ b/test/find.nim @@ -12,3 +12,7 @@ suite "find": check("1 2 3 4 5 ".findAll(initRegex(r" ", "S")).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"]) diff --git a/test/split.nim b/test/split.nim index dc12a2bb41..8366f801f7 100644 --- a/test/split.nim +++ b/test/split.nim @@ -8,3 +8,6 @@ suite "string splitting": check("1 2 ".split(initRegex(" ", "S")) == @["1", "", "2", "", ""]) check("1 2".split(initRegex(" ", "S")) == @["1", "2"]) check("foo".split(initRegex("foo")) == @["", ""]) + + test "captured patterns": + check("12".split(re"(\d)") == @["", "1", "", "2", ""])