summaryrefslogtreecommitdiff
path: root/src/test/test-utf8.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-04-18 10:57:01 +0200
committerLennart Poettering <lennart@poettering.net>2018-04-18 12:51:15 +0200
commit7c6c2e07fcce75555ec093b2f78bb92bb0b66ee4 (patch)
treec9b97edb6a079e6b7782287cf6ad72355452e4bb /src/test/test-utf8.c
parent99f1229d76da4b805f8f6c6e5e4a878d17d42f93 (diff)
downloadsystemd-7c6c2e07fcce75555ec093b2f78bb92bb0b66ee4.tar.gz
test-utf8: add a smoke test for utf8_console_width()
Diffstat (limited to 'src/test/test-utf8.c')
-rw-r--r--src/test/test-utf8.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c
index a7bbc9b426..ec963437b7 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;
}