diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-06-24 23:40:18 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-06-24 23:40:18 +0800 |
commit | 1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1 (patch) | |
tree | f7b957645b11bc19ecf7fb29baaa13530557af7a /Godeps/_workspace/src/github.com/gizak/termui/helper_test.go | |
parent | 92ef33d97a437dce2d7b55f06342de388d95f575 (diff) | |
download | go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.tar.gz go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.tar.zst go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.zip |
Godeps: remove mist remnants, add termui deps
Diffstat (limited to 'Godeps/_workspace/src/github.com/gizak/termui/helper_test.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/gizak/termui/helper_test.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/gizak/termui/helper_test.go b/Godeps/_workspace/src/github.com/gizak/termui/helper_test.go new file mode 100644 index 000000000..6d1a56130 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gizak/termui/helper_test.go @@ -0,0 +1,58 @@ +// Copyright 2015 Zack Guo <gizak@icloud.com>. All rights reserved. +// Use of this source code is governed by a MIT license that can +// be found in the LICENSE file. + +package termui + +import ( + "testing" + + "github.com/davecgh/go-spew/spew" +) + +func TestStr2Rune(t *testing.T) { + s := "你好,世界." + rs := str2runes(s) + if len(rs) != 6 { + t.Error() + } +} + +func TestWidth(t *testing.T) { + s0 := "つのだ☆HIRO" + s1 := "11111111111" + spew.Dump(s0) + spew.Dump(s1) + // above not align for setting East Asian Ambiguous to wide!! + + if strWidth(s0) != strWidth(s1) { + t.Error("str len failed") + } + + len1 := []rune{'a', '2', '&', '「', 'オ', '。'} //will false: 'ᆵ', 'ᄚ', 'ᄒ' + for _, v := range len1 { + if charWidth(v) != 1 { + t.Error("len1 failed") + } + } + + len2 := []rune{'漢', '字', '한', '자', '你', '好', 'だ', '。', '%', 's', 'E', 'ョ', '、', 'ヲ'} + for _, v := range len2 { + if charWidth(v) != 2 { + t.Error("len2 failed") + } + } +} + +func TestTrim(t *testing.T) { + s := "つのだ☆HIRO" + if string(trimStr2Runes(s, 10)) != "つのだ☆HI"+dot { + t.Error("trim failed") + } + if string(trimStr2Runes(s, 11)) != "つのだ☆HIRO" { + t.Error("avoid tail trim failed") + } + if string(trimStr2Runes(s, 15)) != "つのだ☆HIRO" { + t.Error("avoid trim failed") + } +} |