diff options
-rw-r--r-- | src/gui/gui-chat.c | 4 | ||||
-rw-r--r-- | tests/unit/core/test-eval.cpp | 30 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 02891ef06..5fc018dba 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -224,7 +224,7 @@ gui_chat_string_add_offset_screen (const char *string, int offset_screen) { int size_on_screen; - while (string && string[0] && (offset_screen > 0)) + while (string && string[0] && (offset_screen >= 0)) { string = gui_chat_string_next_char (NULL, NULL, (unsigned char *)string, @@ -233,6 +233,8 @@ gui_chat_string_add_offset_screen (const char *string, int offset_screen) { size_on_screen = gui_chat_char_size_screen (string); offset_screen -= size_on_screen; + if (offset_screen < 0) + return string; string = utf8_next_char (string); } } 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}"); |