From 7c6c2e07fcce75555ec093b2f78bb92bb0b66ee4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 18 Apr 2018 10:57:01 +0200 Subject: [PATCH] test-utf8: add a smoke test for utf8_console_width() --- src/test/test-utf8.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c index a7bbc9b..ec96343 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; } -- 2.7.4