summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2017-04-24 22:37:49 +0200
committerSébastien Helleu <flashcode@flashtux.org>2017-04-24 22:37:49 +0200
commit112bebcddf99d5187ede8ebbe765abc75373c4f2 (patch)
tree3430bc6a930518eb0fe325c93bd7217d823083c6 /tests/unit
parent0470a71af9e9da57b39702f94705f5f43cec5448 (diff)
downloadweechat-112bebcddf99d5187ede8ebbe765abc75373c4f2.zip
core: add a way to count the suffix length in max chars displayed in cut of string ("cut:" and "cutscr:") (closes #963)
The format to use is one of: - ${cut:+max,suffix,string} - ${cutscr:+max,suffix,string} With the "+" before max, WeeChat ensures there are at most "max" chars in output, including the length of suffix string.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/core/test-eval.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/unit/core/test-eval.cpp b/tests/unit/core/test-eval.cpp
index e0bd236b7..14f60f80b 100644
--- a/tests/unit/core/test-eval.cpp
+++ b/tests/unit/core/test-eval.cpp
@@ -237,6 +237,42 @@ TEST(Eval, EvalExpression)
WEE_CHECK_EVAL("te+", "${cut:2,+,test}");
WEE_CHECK_EVAL("te+", "${cutscr:2,+,test}");
+ WEE_CHECK_EVAL("tes", "${cut:3,,test}");
+ WEE_CHECK_EVAL("tes", "${cutscr:3,,test}");
+ WEE_CHECK_EVAL("tes", "${cut:+3,,test}");
+ WEE_CHECK_EVAL("tes", "${cutscr:+3,,test}");
+
+ WEE_CHECK_EVAL("tes+", "${cut:3,+,test}");
+ WEE_CHECK_EVAL("tes+", "${cutscr:3,+,test}");
+ WEE_CHECK_EVAL("tes++", "${cut:3,++,test}");
+ WEE_CHECK_EVAL("tes++", "${cutscr:3,++,test}");
+ WEE_CHECK_EVAL("tes+++", "${cut:3,+++,test}");
+ WEE_CHECK_EVAL("tes+++", "${cutscr:3,+++,test}");
+ WEE_CHECK_EVAL("tes++++", "${cut:3,++++,test}");
+ WEE_CHECK_EVAL("tes++++", "${cutscr:3,++++,test}");
+ WEE_CHECK_EVAL("tes…", "${cut:3,…,test}");
+ WEE_CHECK_EVAL("tes…", "${cutscr:3,…,test}");
+ WEE_CHECK_EVAL("te+", "${cut:+3,+,test}");
+ WEE_CHECK_EVAL("te+", "${cutscr:+3,+,test}");
+ WEE_CHECK_EVAL("…", "${cut:+3,…,test}");
+ WEE_CHECK_EVAL("te…", "${cutscr:+3,…,test}");
+ WEE_CHECK_EVAL("t++", "${cut:+3,++,test}");
+ WEE_CHECK_EVAL("t++", "${cutscr:+3,++,test}");
+ WEE_CHECK_EVAL("+++", "${cut:+3,+++,test}");
+ WEE_CHECK_EVAL("+++", "${cutscr:+3,+++,test}");
+ WEE_CHECK_EVAL("", "${cut:+3,++++,test}");
+ WEE_CHECK_EVAL("", "${cutscr:+3,++++,test}");
+
+ WEE_CHECK_EVAL("test", "${cut:4,,test}");
+ WEE_CHECK_EVAL("test", "${cutscr:4,,test}");
+ WEE_CHECK_EVAL("test", "${cut:+4,,test}");
+ WEE_CHECK_EVAL("test", "${cutscr:+4,,test}");
+
+ WEE_CHECK_EVAL("test", "${cut:4,+,test}");
+ WEE_CHECK_EVAL("test", "${cutscr:4,+,test}");
+ WEE_CHECK_EVAL("test", "${cut:+4,+,test}");
+ WEE_CHECK_EVAL("test", "${cutscr:+4,+,test}");
+
WEE_CHECK_EVAL("éà", "${cut:2,,éàô}");
WEE_CHECK_EVAL("éà", "${cutscr:2,,éàô}");