about summary refs log tree commit diff stats
path: root/tests/test_common.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-01-17 21:09:40 +0000
committerJames Booth <boothj5@gmail.com>2015-01-17 21:09:40 +0000
commitba89297382a40ea8f63f73d756dc1ad67a0b1aaa (patch)
tree3f434417237a05f8a91f7921bc73f7a31043eb26 /tests/test_common.c
parent4ac11ddcd69a00fff6430e92d79f0e1e56430c77 (diff)
downloadprofani-tty-ba89297382a40ea8f63f73d756dc1ad67a0b1aaa.tar.gz
Added utf8_display_len
Diffstat (limited to 'tests/test_common.c')
-rw-r--r--tests/test_common.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_common.c b/tests/test_common.c
index bac03cfd..0c4530a0 100644
--- a/tests/test_common.c
+++ b/tests/test_common.c
@@ -544,3 +544,46 @@ void test_p_sha1_hash7(void **state)
 
     assert_string_equal(result, "bNfKVfqEOGmzlH8M+e8FYTB46SU=");
 }
+
+void utf8_display_len_null_str(void **state)
+{
+    int result = utf8_display_len(NULL);
+
+    assert_int_equal(0, result);
+}
+
+void utf8_display_len_1_non_wide(void **state)
+{
+    int result = utf8_display_len("1");
+
+    assert_int_equal(1, result);
+}
+
+void utf8_display_len_1_wide(void **state)
+{
+    int result = utf8_display_len("四");
+
+    assert_int_equal(2, result);
+}
+
+void utf8_display_len_non_wide(void **state)
+{
+    int result = utf8_display_len("123456789abcdef");
+
+    assert_int_equal(15, result);
+}
+
+void utf8_display_len_wide(void **state)
+{
+    int result = utf8_display_len("12三四56");
+
+    assert_int_equal(8, result);
+}
+
+void utf8_display_len_all_wide(void **state)
+{
+    int result = utf8_display_len("ひらがな");
+
+    assert_int_equal(8, result);
+}
+