From: Zbigniew Jędrzejewski-Szmek Date: Wed, 18 Apr 2018 08:57:01 +0000 (+0200) Subject: test-utf8: add a smoke test for utf8_console_width() X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=46030154635721dd13254eb5bdacfaa4382e45e3;p=elogind.git test-utf8: add a smoke test for utf8_console_width() --- diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c index a7bbc9b42..ec963437b 100644 --- a/src/test/test-utf8.c +++ b/src/test/test-utf8.c @@ -102,6 +102,15 @@ static void test_utf8_n_codepoints(void) { assert_se(utf8_n_codepoints("\xF1") == (size_t) -1); } +static void test_utf8_console_width(void) { + assert_se(utf8_console_width("abc") == 3); + assert_se(utf8_console_width("zażółcić gęślą jaźń") == 19); + assert_se(utf8_console_width("串") == 2); + assert_se(utf8_console_width("") == 0); + assert_se(utf8_console_width("…👊🔪💐…") == 8); + assert_se(utf8_console_width("\xF1") == (size_t) -1); +} + int main(int argc, char *argv[]) { test_utf8_is_valid(); test_utf8_is_printable(); @@ -111,6 +120,7 @@ int main(int argc, char *argv[]) { test_utf8_escaping_printable(); test_utf16_to_utf8(); test_utf8_n_codepoints(); + test_utf8_console_width(); return 0; }