MCPcopy Create free account
hub / github.com/git/git / test_utf8_width__strwidth_chinese

Function test_utf8_width__strwidth_chinese

t/unit-tests/u-utf8-width.c:47–65  ·  view source on GitHub ↗

* Tests for utf8_strwidth (simpler version without length limit) */

Source from the content-addressed store, hash-verified

45 * Tests for utf8_strwidth (simpler version without length limit)
46 */
47void test_utf8_width__strwidth_chinese(void)
48{
49 /* Test basic ASCII */
50 cl_assert_equal_i(5, utf8_strwidth("Hello"));
51
52 /* Test Chinese characters */
53 /* 2 Chinese chars = 4 display columns */
54 cl_assert_equal_i(4, utf8_strwidth("你好"));
55
56 /* Test longer Chinese string */
57 /* 5 Chinese chars = 10 display columns */
58 cl_assert_equal_i(10, utf8_strwidth("你好世界!"));
59
60 /* Test mixed ASCII and Chinese */
61 /* 5 ASCII (5 cols) + 2 Chinese (4 cols) = 9 */
62 cl_assert_equal_i(9, utf8_strwidth("Hello世界"));
63 /* 2 ASCII (2 cols) + 2 Chinese (4 cols) + 1 ASCII (1 col) = 7 */
64 cl_assert_equal_i(7, utf8_strwidth("Hi世界!"));
65}
66
67/*
68 * Additional tests with other East Asian characters

Callers

nothing calls this directly

Calls 1

utf8_strwidthFunction · 0.85

Tested by

no test coverage detected