diff options
author | Yang Zhang <yang_zhang@iapcm.ac.cn> | 2018-12-26 22:49:25 +0800 |
---|---|---|
committer | Yang Zhang <yang_zhang@iapcm.ac.cn> | 2018-12-26 22:55:16 +0800 |
commit | 3fa2d15fb899c937900083fd7de696599371ce47 (patch) | |
tree | 7d8fd43e4eca7dfde65567714d3d35a6bfaf6a65 /util/text/text_test.go | |
parent | 8a6a8055d723e523d9943244b042c778d75b02cc (diff) | |
download | git-bug-3fa2d15fb899c937900083fd7de696599371ce47.tar.gz |
Implement displaying CJK contents
Diffstat (limited to 'util/text/text_test.go')
-rw-r--r-- | util/text/text_test.go | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/util/text/text_test.go b/util/text/text_test.go index cf72431e..38e747df 100644 --- a/util/text/text_test.go +++ b/util/text/text_test.go @@ -199,73 +199,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 - { - "快檢什麼望對", - 2, - "快檢", "什麼望對", - }, - { - "快檢什麼望對", - 3, - "快檢什", "麼望對", - }, - // Handle chinese with colors - { - "快\x1b[31m檢什麼\x1b[0m望對", - 2, - "快\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) - } - } -} |