summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-11-23 08:20:01 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-11-23 08:49:54 +0100
commit479ab5bc58ac006512187ceb839223abdea242fa (patch)
tree74710c7343465b92dc8312ec911ce206e9b05d76 /tests/unit
parent87f74e9f9544a7e3b7e4ffd0acc40841b8eb79e8 (diff)
downloadweechat-479ab5bc58ac006512187ceb839223abdea242fa.zip
core: evaluate expressions even when the suffix is missing (issue #2042, issue #1714)
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/core/test-core-eval.cpp3
-rw-r--r--tests/unit/core/test-core-string.cpp21
2 files changed, 16 insertions, 8 deletions
diff --git a/tests/unit/core/test-core-eval.cpp b/tests/unit/core/test-core-eval.cpp
index 4c0163511..faae52eff 100644
--- a/tests/unit/core/test-core-eval.cpp
+++ b/tests/unit/core/test-core-eval.cpp
@@ -988,7 +988,8 @@ TEST(CoreEval, EvalExpression)
hashtable_set (pointers, "my_null_pointer", (const void *)0x0);
hashtable_set (pointers, "my_buffer_pointer", gui_buffers);
hashtable_set (pointers, "my_other_pointer", (const void *)0x1234abcd);
- WEE_CHECK_EVAL("x", "x${buffer.number");
+ WEE_CHECK_EVAL("x", "x${buffer.numbe");
+ WEE_CHECK_EVAL("x1", "x${buffer.number");
WEE_CHECK_EVAL("x${buffer.number}1",
"x\\${buffer.number}${buffer.number}");
WEE_CHECK_EVAL("1", "${buffer.number}");
diff --git a/tests/unit/core/test-core-string.cpp b/tests/unit/core/test-core-string.cpp
index a3e22ee2c..ea760feb3 100644
--- a/tests/unit/core/test-core-string.cpp
+++ b/tests/unit/core/test-core-string.cpp
@@ -1308,20 +1308,23 @@ TEST(CoreString, Highlight)
/*
* Test callback for function string_replace_with_callback.
*
- * It replaces "abc" by "def", "xxx" by empty string, and for any other value
+ * It replaces "abc" by "def", "empty" by empty string, and for any other value
* it returns NULL (so the value is kept as-is).
*/
char *
-test_replace_cb (void *data, const char *text)
+test_replace_cb (void *data,
+ const char *prefix, const char *text, const char *suffix)
{
/* make C++ compiler happy */
(void) data;
+ (void) prefix;
+ (void) suffix;
if (strcmp (text, "abc") == 0)
return strdup ("def");
- if (strcmp (text, "xxx") == 0)
+ if (strcmp (text, "empty") == 0)
return strdup ("");
if (strncmp (text, "no_replace:", 11) == 0)
@@ -1446,13 +1449,17 @@ TEST(CoreString, ReplaceWithCallback)
&test_replace_cb, NULL, &errors);
WEE_REPLACE_CB("test def", 0, "test ${abc}", "${", "}", NULL,
&test_replace_cb, NULL, &errors);
- WEE_REPLACE_CB("test ", 0, "test ${xxx}", "${", "}", NULL,
+ WEE_REPLACE_CB("test ", 0, "test ${empty}", "${", "}", NULL,
+ &test_replace_cb, NULL, &errors);
+ WEE_REPLACE_CB("test ${aaa", 1, "test ${aaa", "${", "}", NULL,
+ &test_replace_cb, NULL, &errors);
+ WEE_REPLACE_CB("test ", 0, "test ${empty", "${", "}", NULL,
&test_replace_cb, NULL, &errors);
WEE_REPLACE_CB("test ${aaa}", 1, "test ${aaa}", "${", "}", NULL,
&test_replace_cb, NULL, &errors);
- WEE_REPLACE_CB("test def ${aaa}", 1, "test ${abc} ${xxx} ${aaa}",
+ WEE_REPLACE_CB("test def ${aaa}", 1, "test ${abc} ${empty} ${aaa}",
"${", "}", NULL, &test_replace_cb, NULL, &errors);
- WEE_REPLACE_CB("test ", 1, "test ${abc", "${", "}", NULL,
+ WEE_REPLACE_CB("test def", 0, "test ${abc", "${", "}", NULL,
&test_replace_cb, NULL, &errors);
WEE_REPLACE_CB("test abc}", 0, "test abc}", "${", "}", NULL,
&test_replace_cb, NULL, &errors);
@@ -1462,7 +1469,7 @@ TEST(CoreString, ReplaceWithCallback)
&test_replace_cb, NULL, &errors);
WEE_REPLACE_CB("def", 0, "${abc}", "${", "}", NULL,
&test_replace_cb, NULL, &errors);
- WEE_REPLACE_CB("", 0, "${xxx}", "${", "}", NULL,
+ WEE_REPLACE_CB("", 0, "${empty}", "${", "}", NULL,
&test_replace_cb, NULL, &errors);
WEE_REPLACE_CB("${aaa}", 1, "${aaa}", "${", "}", NULL,
&test_replace_cb, NULL, &errors);