aboutsummaryrefslogtreecommitdiffstats
path: root/util/text/text_test.go
diff options
context:
space:
mode:
authorYang Zhang <yang_zhang@iapcm.ac.cn>2018-12-26 23:05:58 +0800
committerYang Zhang <yang_zhang@iapcm.ac.cn>2018-12-26 23:05:58 +0800
commitd31891504d201423f512d897d44dd71b06dad93d (patch)
tree0d5d5ba5597cb0fcb14a1adcc23ca6eb79c95fe6 /util/text/text_test.go
parent32b3e263fc8443f6089b9de8fbce833369461982 (diff)
parent3fa2d15fb899c937900083fd7de696599371ce47 (diff)
downloadgit-bug-d31891504d201423f512d897d44dd71b06dad93d.tar.gz
Implement almost full CJK support.
Display of CJK contents are supported. Adding CJK tags are problematic.
Diffstat (limited to 'util/text/text_test.go')
-rw-r--r--util/text/text_test.go70
1 files changed, 0 insertions, 70 deletions
diff --git a/util/text/text_test.go b/util/text/text_test.go
index f5b15a43..c70d2ccd 100644
--- a/util/text/text_test.go
+++ b/util/text/text_test.go
@@ -203,73 +203,3 @@ func TestWordLen(t *testing.T) {
}
}
}
-
-func TestSplitWord(t *testing.T) {
- cases := []struct {
- Input string
- Length int
- Result, Leftover string
- }{
- // A simple word passes through.
- {
- "foo",
- 4,
- "foo", "",
- },
- // Cut at the right place
- {
- "foobarHoy",
- 4,
- "foob", "arHoy",
- },
- // A simple word passes through with colors
- {
- "\x1b[31mbar\x1b[0m",
- 4,
- "\x1b[31mbar\x1b[0m", "",
- },
- // Cut at the right place with colors
- {
- "\x1b[31mfoobarHoy\x1b[0m",
- 4,
- "\x1b[31mfoob", "arHoy\x1b[0m",
- },
- // Handle prefix and suffix properly
- {
- "foo\x1b[31mfoobarHoy\x1b[0mbaaar",
- 4,
- "foo\x1b[31mf", "oobarHoy\x1b[0mbaaar",
- },
- // Cut properly with length = 0
- {
- "foo",
- 0,
- "", "foo",
- },
- // Handle chinese
- {
- "快檢什麼望對",
- 4,
- "快檢", "什麼望對",
- },
- {
- "快檢什麼望對",
- 5,
- "快檢", "什麼望對",
- },
- // Handle chinese with colors
- {
- "快\x1b[31m檢什麼\x1b[0m望對",
- 4,
- "快\x1b[31m檢", "什麼\x1b[0m望對",
- },
- }
-
- for i, tc := range cases {
- result, leftover := splitWord(tc.Input, tc.Length)
- if result != tc.Result || leftover != tc.Leftover {
- t.Fatalf("Case %d Input:\n\n`%s`\n\nExpected Output:\n\n`%s` - `%s`\n\nActual Output:\n\n`%s` - `%s`",
- i, tc.Input, tc.Result, tc.Leftover, result, leftover)
- }
- }
-}