aboutsummaryrefslogtreecommitdiffstats
path: root/util/text/text_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-12-23 19:00:51 +0100
committerMichael Muré <batolettre@gmail.com>2018-12-23 19:00:51 +0100
commitf9fc85ac825fec05a26d4029da15b33ae66e4e25 (patch)
tree9e807bf1435001b1763e77c851b6ca1f8b3398be /util/text/text_test.go
parent0d5bd6b18afde898e610746657a87080235f6222 (diff)
downloadgit-bug-f9fc85ac825fec05a26d4029da15b33ae66e4e25.tar.gz
text: hopefuly fix the handling of chinese
Diffstat (limited to 'util/text/text_test.go')
-rw-r--r--util/text/text_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/util/text/text_test.go b/util/text/text_test.go
index 96234464..cda26fda 100644
--- a/util/text/text_test.go
+++ b/util/text/text_test.go
@@ -89,6 +89,18 @@ func TestWrap(t *testing.T) {
" This\nis a\nlist:\n\n\n *\nfoo\n *\nbar\n\n\n *\nbaz\nBAM\n",
6,
},
+ // Handle chinese
+ {
+ "婞一枳郲逴靲屮蜧曀殳,掫乇峔掮傎溒兀緉冘仜。",
+ "婞一枳郲逴靲屮蜧曀殳,掫\n乇峔掮傎溒兀緉冘仜。",
+ 12,
+ },
+ // Handle chinese with colors
+ {
+ "婞一枳郲逴\x1b[31m靲屮蜧曀殳,掫乇峔掮傎溒\x1b[0m兀緉冘仜。",
+ "婞一枳郲逴\x1b[31m靲屮蜧曀殳,掫\n乇峔掮傎溒\x1b[0m兀緉冘仜。",
+ 12,
+ },
}
for i, tc := range cases {
@@ -126,6 +138,16 @@ func TestWordLen(t *testing.T) {
"foo\x1b[31mfoobarHoy\x1b[0mbaaar",
17,
},
+ // Handle chinese
+ {
+ "快檢什麼望對",
+ 6,
+ },
+ // Handle chinese with colors
+ {
+ "快\x1b[31m檢什麼\x1b[0m望對",
+ 6,
+ },
}
for i, tc := range cases {
@@ -179,6 +201,18 @@ func TestSplitWord(t *testing.T) {
0,
"", "foo",
},
+ // Handle chinese
+ {
+ "快檢什麼望對",
+ 2,
+ "快檢", "什麼望對",
+ },
+ // Handle chinese with colors
+ {
+ "快\x1b[31m檢什麼\x1b[0m望對",
+ 2,
+ "快\x1b[31m檢", "什麼\x1b[0m望對",
+ },
}
for i, tc := range cases {