From 8b8224ecaf7ed8cfbe1a205b43c3402aabc1653f Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Sun, 12 Apr 2015 17:31:43 +0300 Subject: [PATCH] Add tests for empty or non-empty match --- test/misc.nim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/misc.nim b/test/misc.nim index a515db889e..1340cdc432 100644 --- a/test/misc.nim +++ b/test/misc.nim @@ -1,6 +1,16 @@ -import unittest, nre, optional_t.nonstrict +import unittest, nre, strutils, optional_t.nonstrict suite "Misc tests": test "unicode": check("".find(re("", "8")).match == "") check("перевірка".replace(re(r"\w", "uW"), "") == "") + + test "empty or non-empty match": + check("abc".findall(re"|.").join(":") == ":a::b::c:") + check("abc".findall(re".|").join(":") == "a:b:c:") + + check("abc".replace(re"|.", "x") == "xxxxxxx") + check("abc".replace(re".|", "x") == "xxxx") + + check("abc".split(re"|.").join(":") == ":::::") + check("abc".split(re".|").join(":") == ":::")