summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2017-03-28 20:45:31 +0200
committerSébastien Helleu <flashcode@flashtux.org>2017-03-28 20:45:31 +0200
commit30450214307e3eba72dd411e0c700163341d7cdf (patch)
treec54d88ddc1710f00ef9e2e946c171e1228f85422 /tests
parentee82ba74616b9050346d01e27b452bee3c5f0afd (diff)
downloadweechat-30450214307e3eba72dd411e0c700163341d7cdf.zip
core: fix cut of chars in "cutscr" of evaluated strings
This fixes two problems: - stop before max char displayed with wide chars - preserve combining chars in the output Before the fix (wrong): >> ${cutscr:3,+,こんにちは世界} == [こん+] >> ${cutscr:1,+,a${\u0308}} == [a+] After the fix (OK): >> ${cutscr:3,+,こんにちは世界} == [こ+] >> ${cutscr:1,+,a${\u0308}} == [ä]
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/core/test-eval.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/core/test-eval.cpp b/tests/unit/core/test-eval.cpp
index 78b805119..b0fc3384e 100644
--- a/tests/unit/core/test-eval.cpp
+++ b/tests/unit/core/test-eval.cpp
@@ -220,16 +220,46 @@ TEST(Eval, EvalExpression)
/* test cut of chars */
WEE_CHECK_EVAL("", "${cut:0,,}");
+ WEE_CHECK_EVAL("", "${cutscr:0,,}");
+
WEE_CHECK_EVAL("", "${cut:0,+,}");
+ WEE_CHECK_EVAL("", "${cutscr:0,+,}");
+
WEE_CHECK_EVAL("", "${cut:0,,test}");
+ WEE_CHECK_EVAL("", "${cutscr:0,,test}");
+
WEE_CHECK_EVAL("+", "${cut:0,+,test}");
+ WEE_CHECK_EVAL("+", "${cutscr:0,+,test}");
+
WEE_CHECK_EVAL("te", "${cut:2,,test}");
+ WEE_CHECK_EVAL("te", "${cutscr:2,,test}");
+
WEE_CHECK_EVAL("te+", "${cut:2,+,test}");
+ WEE_CHECK_EVAL("te+", "${cutscr:2,+,test}");
+
WEE_CHECK_EVAL("éà", "${cut:2,,éàô}");
+ WEE_CHECK_EVAL("éà", "${cutscr:2,,éàô}");
+
WEE_CHECK_EVAL("éà+", "${cut:2,+,éàô}");
+ WEE_CHECK_EVAL("éà+", "${cutscr:2,+,éàô}");
+
+ WEE_CHECK_EVAL("こ+", "${cut:1,+,こんにちは世界}");
+ WEE_CHECK_EVAL("+", "${cutscr:1,+,こんにちは世界}");
+
WEE_CHECK_EVAL("こん+", "${cut:2,+,こんにちは世界}");
WEE_CHECK_EVAL("こ+", "${cutscr:2,+,こんにちは世界}");
+ WEE_CHECK_EVAL("こんに+", "${cut:3,+,こんにちは世界}");
+ WEE_CHECK_EVAL("こ+", "${cutscr:3,+,こんにちは世界}");
+
+ WEE_CHECK_EVAL("こんにち+", "${cut:4,+,こんにちは世界}");
+ WEE_CHECK_EVAL("こん+", "${cutscr:4,+,こんにちは世界}");
+
+ WEE_CHECK_EVAL("こんにちは+", "${cut:5,+,こんにちは世界}");
+ WEE_CHECK_EVAL("こん+", "${cutscr:4,+,こんにちは世界}");
+
+ WEE_CHECK_EVAL("こん+", "${cutscr:4,+,こんにちは世界}");
+
/* test color */
WEE_CHECK_EVAL(gui_color_get_custom ("green"), "${color:green}");
WEE_CHECK_EVAL(gui_color_get_custom ("*214"), "${color:*214}");