-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpadder_test.go
65 lines (60 loc) · 883 Bytes
/
padder_test.go
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
package main
import (
"testing"
)
func TestPadding_Fill(t *testing.T) {
for _, tt := range []struct {
In string
Width int
Out string
}{
{
In: "foobar",
Width: 10,
Out: "foobar ",
},
{
In: "–",
Width: 5,
Out: "– ",
},
{
In: "世界",
Width: 6,
Out: "世界 ",
},
} {
got := fill(tt.In, tt.Width)
if got != tt.Out {
t.Errorf("got = %q; want = %q", got, tt.Out)
}
}
}
func TestPadding_Justify(t *testing.T) {
for _, tt := range []struct {
In string
Width int
Out string
}{
{
In: "foobar",
Width: 10,
Out: " foobar",
},
{
In: "–",
Width: 5,
Out: " –",
},
{
In: "世界",
Width: 6,
Out: " 世界",
},
} {
got := just(tt.In, tt.Width)
if got != tt.Out {
t.Errorf("got = %q; want = %q", got, tt.Out)
}
}
}