From b460055f78db0554de43aa90ec5c7509350b68a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 23 Nov 2014 08:32:52 +0100 Subject: [PATCH] tests: add tests of regex replace with empty regex or regex_replace --- tests/unit/core/test-eval.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/unit/core/test-eval.cpp b/tests/unit/core/test-eval.cpp index d9fc79241..eb17603b0 100644 --- a/tests/unit/core/test-eval.cpp +++ b/tests/unit/core/test-eval.cpp @@ -262,6 +262,24 @@ TEST(Eval, EvalReplaceRegex) NULL, NULL); CHECK(options); + /* replace regex by empty string */ + hashtable_remove (pointers, "regex"); + hashtable_set (options, "regex", ".*"); + hashtable_set (options, "regex_replace", ""); + WEE_CHECK_EVAL("", "test"); + + /* replace empty regex */ + hashtable_remove (pointers, "regex"); + hashtable_set (options, "regex", ""); + hashtable_set (options, "regex_replace", "abc"); + WEE_CHECK_EVAL("test", "test"); + + /* replace empty regex by empty string */ + hashtable_remove (pointers, "regex"); + hashtable_set (options, "regex", ""); + hashtable_set (options, "regex_replace", ""); + WEE_CHECK_EVAL("test", "test"); + /* add brackets around URLs (regex as string) */ hashtable_remove (pointers, "regex"); hashtable_set (options, "regex", "\\w+://\\S+");