forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtruncate_test.go
More file actions
71 lines (69 loc) · 1.18 KB
/
truncate_test.go
File metadata and controls
71 lines (69 loc) · 1.18 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
package text
import "testing"
func TestTruncate(t *testing.T) {
type args struct {
max int
s string
}
tests := []struct {
name string
args args
want string
}{
{
name: "Japanese",
args: args{
max: 11,
s: "テストテストテストテスト",
},
want: "テストテ...",
},
{
name: "Japanese filled",
args: args{
max: 11,
s: "aテストテストテストテスト",
},
want: "aテスト... ",
},
{
name: "Chinese",
args: args{
max: 11,
s: "幫新舉報違章工廠新增編號",
},
want: "幫新舉報...",
},
{
name: "Chinese filled",
args: args{
max: 11,
s: "a幫新舉報違章工廠新增編號",
},
want: "a幫新舉... ",
},
{
name: "Korean",
args: args{
max: 11,
s: "프로젝트 내의",
},
want: "프로젝트...",
},
{
name: "Korean filled",
args: args{
max: 11,
s: "a프로젝트 내의",
},
want: "a프로젝... ",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Truncate(tt.args.max, tt.args.s); got != tt.want {
t.Errorf("Truncate() = %q, want %q", got, tt.want)
}
})
}
}