From f99c866f352c9bc7f3ba0e7d228a5942dd616de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Mon, 27 Mar 2017 21:14:51 +0200 Subject: core: add cut of string with max chars displayed in evaluation of expressions The syntax is: ${cutscr:max,suffix,string}. The string is cut after max chars displayed on screen. If the string is cut, the optional suffix is added after. --- tests/tests.cpp | 4 ++-- tests/unit/core/test-eval.cpp | 2 ++ tests/unit/core/test-utf8.cpp | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/tests.cpp b/tests/tests.cpp index ceda4144d..098feea65 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -126,8 +126,8 @@ main (int argc, char *argv[]) int rc, length, weechat_argc; char *weechat_tests_args, *args, **weechat_argv; - /* setup environment: default language, no specific timezone */ - setenv ("LC_ALL", "C", 1); + /* setup environment: English language, no specific timezone */ + setenv ("LC_ALL", "en_US.UTF-8", 1); setenv ("TZ", "", 1); /* build arguments for WeeChat */ diff --git a/tests/unit/core/test-eval.cpp b/tests/unit/core/test-eval.cpp index 92914f8d4..78b805119 100644 --- a/tests/unit/core/test-eval.cpp +++ b/tests/unit/core/test-eval.cpp @@ -227,6 +227,8 @@ TEST(Eval, EvalExpression) WEE_CHECK_EVAL("te+", "${cut:2,+,test}"); WEE_CHECK_EVAL("éà", "${cut:2,,éàô}"); WEE_CHECK_EVAL("éà+", "${cut:2,+,éàô}"); + WEE_CHECK_EVAL("こん+", "${cut:2,+,こんにちは世界}"); + WEE_CHECK_EVAL("こ+", "${cutscr:2,+,こんにちは世界}"); /* test color */ WEE_CHECK_EVAL(gui_color_get_custom ("green"), "${color:green}"); diff --git a/tests/unit/core/test-utf8.cpp b/tests/unit/core/test-utf8.cpp index 1bdf9b427..ca8ccfd22 100644 --- a/tests/unit/core/test-utf8.cpp +++ b/tests/unit/core/test-utf8.cpp @@ -354,8 +354,7 @@ TEST(Utf8, Size) LONGS_EQUAL(1, utf8_char_size_screen ("A")); LONGS_EQUAL(1, utf8_char_size_screen ("ë")); LONGS_EQUAL(1, utf8_char_size_screen ("€")); - /* this test does not work on Ubuntu Precise: it returns 2 instead of 1 */ - /*LONGS_EQUAL(1, utf8_char_size_screen (han_char));*/ + LONGS_EQUAL(2, utf8_char_size_screen (han_char)); /* length of string (in chars) */ LONGS_EQUAL(0, utf8_strlen (NULL)); -- cgit v1.2.3