From 9a8ec36cbda56dfd255a21d8b185e5361162dbfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Tue, 14 Mar 2017 07:25:03 +0100 Subject: core: add cut of string in evaluation of expressions The syntax is: ${cut:max,suffix,string}. The string is cut after max chars. If the string is cut, the optional suffix is added after. --- tests/unit/core/test-eval.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/unit/core') diff --git a/tests/unit/core/test-eval.cpp b/tests/unit/core/test-eval.cpp index e2ecd401a..92914f8d4 100644 --- a/tests/unit/core/test-eval.cpp +++ b/tests/unit/core/test-eval.cpp @@ -218,6 +218,16 @@ TEST(Eval, EvalExpression) WEE_CHECK_EVAL("********", "${hide:*,password}"); WEE_CHECK_EVAL("\u2603\u2603\u2603", "${hide:${esc:\u2603},abc}"); + /* test cut of chars */ + WEE_CHECK_EVAL("", "${cut:0,,}"); + WEE_CHECK_EVAL("", "${cut:0,+,}"); + WEE_CHECK_EVAL("", "${cut:0,,test}"); + WEE_CHECK_EVAL("+", "${cut:0,+,test}"); + WEE_CHECK_EVAL("te", "${cut:2,,test}"); + WEE_CHECK_EVAL("te+", "${cut:2,+,test}"); + WEE_CHECK_EVAL("éà", "${cut:2,,éàô}"); + WEE_CHECK_EVAL("éà+", "${cut:2,+,éàô}"); + /* test color */ WEE_CHECK_EVAL(gui_color_get_custom ("green"), "${color:green}"); WEE_CHECK_EVAL(gui_color_get_custom ("*214"), "${color:*214}"); -- cgit v1.2.3