diff options
author | James Booth <boothj5@gmail.com> | 2015-01-17 21:09:40 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-01-17 21:09:40 +0000 |
commit | ba89297382a40ea8f63f73d756dc1ad67a0b1aaa (patch) | |
tree | 3f434417237a05f8a91f7921bc73f7a31043eb26 /tests | |
parent | 4ac11ddcd69a00fff6430e92d79f0e1e56430c77 (diff) | |
download | profani-tty-ba89297382a40ea8f63f73d756dc1ad67a0b1aaa.tar.gz |
Added utf8_display_len
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_common.c | 43 | ||||
-rw-r--r-- | tests/test_common.h | 6 | ||||
-rw-r--r-- | tests/testsuite.c | 6 |
3 files changed, 55 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); +} + diff --git a/tests/test_common.h b/tests/test_common.h index 8b5128fd..1866e73d 100644 --- a/tests/test_common.h +++ b/tests/test_common.h @@ -46,3 +46,9 @@ void test_p_sha1_hash5(void **state); void test_p_sha1_hash6(void **state); void test_p_sha1_hash6(void **state); void test_p_sha1_hash7(void **state); +void utf8_display_len_null_str(void **state); +void utf8_display_len_1_non_wide(void **state); +void utf8_display_len_1_wide(void **state); +void utf8_display_len_non_wide(void **state); +void utf8_display_len_wide(void **state); +void utf8_display_len_all_wide(void **state); \ No newline at end of file diff --git a/tests/testsuite.c b/tests/testsuite.c index 32d298cf..cf511c59 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -85,6 +85,12 @@ int main(int argc, char* argv[]) { unit_test(test_p_sha1_hash5), unit_test(test_p_sha1_hash6), unit_test(test_p_sha1_hash7), + unit_test(utf8_display_len_null_str), + unit_test(utf8_display_len_1_non_wide), + unit_test(utf8_display_len_1_wide), + unit_test(utf8_display_len_non_wide), + unit_test(utf8_display_len_wide), + unit_test(utf8_display_len_all_wide), unit_test(clear_empty), unit_test(reset_after_create), |