-
Notifications
You must be signed in to change notification settings - Fork 1
/
padright_test.go
38 lines (26 loc) · 977 Bytes
/
padright_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
package ranges
import "testing"
func TestPadRight(t *testing.T) {
t.Parallel()
assertEqual(t, String(PadRight[rune](Runes("abc"), 'x', 5)), "abcxx")
assertEqual(t, String(PadRight[rune](Runes("abcdef"), 'x', 5)), "abcdef")
assertEqual(t, String(PadRight[rune](Runes(""), 'x', 5)), "xxxxx")
assertEqual(t, String(PadRight[rune](Runes(""), 'x', 0)), "")
assertEqual(t, String(PadRight[rune](Runes(""), 'x', -10)), "")
}
func TestPadRightF(t *testing.T) {
t.Parallel()
assertEqual(t, String(PadRightF(Runes("abc"), 'x', 5)), "abcxx")
assertEqual(t, String(PadRightF(Runes("abcdef"), 'x', 5)), "abcdef")
r := PadRightF(Runes("日"), '本', 3)
r2 := r.Save()
r.PopFront()
r3 := r.Save()
assertEqual(t, String(r2), "日本本")
assertEqual(t, String(r3), "本本")
}
func TestPadRightS(t *testing.T) {
t.Parallel()
assertEqual(t, String(PadRightS([]rune("abc"), 'x', 5)), "abcxx")
assertEqual(t, String(PadRightS([]rune("abcdef"), 'x', 5)), "abcdef")
}