Repository navigation
Expand file tree
/
Copy pathtextprocess_test.go
More file actions
79 lines (62 loc) · 1.9 KB
/
Copy pathtextprocess_test.go
File metadata and controls
79 lines (62 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
tableview: human friendly table viewer
Copyright (C) 2016 OKAMURA, Yasunobu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package main
import (
"testing"
)
func TestSubstringByDisplayWidth(t *testing.T) {
actual1 := substringByDisplayWidth("hogehoge!!", 8)
if "hogehoge" != actual1 {
t.Errorf("Failed in test 1 / (%s)", actual1)
}
actual2 := substringByDisplayWidth("1日本語のヘッダ", 6)
if "1日本" != actual2 {
t.Errorf("Failed in test 2 / (%s)", actual2)
}
}
func TestDisplayWidth(t *testing.T) {
actual1 := displayWidth("hogehoge")
if 8 != actual1 {
t.Errorf("Failed in test 1 / (%d)", actual1)
}
actual2 := displayWidth("日本語のヘッダ")
if 14 != actual2 {
t.Errorf("Failed in test 2 / (%d)", actual2)
}
actual3 := displayWidth("日本語のヘッダ! ")
if 16 != actual3 {
t.Errorf("Failed in test 3 / (%d)", actual3)
}
}
func TestDisplayWidthChar(t *testing.T) {
if 1 != displayWidthChar('a') {
t.Errorf("Failed in test 1")
}
if 1 != displayWidthChar(' ') {
t.Errorf("Failed in test 2")
}
if 1 != displayWidthChar('1') {
t.Errorf("Failed in test 3")
}
if 1 != displayWidthChar('!') {
t.Errorf("Failed in test 4")
}
if 2 != displayWidthChar('日') {
t.Errorf("Failed in test 5")
}
if 2 != displayWidthChar('!') {
t.Errorf("Failed in test 6")
}
}