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
|
package strutil
import (
"testing"
"time"
)
func TestResize(t *testing.T) {
s := "foo"
got := Resize(s, 5)
if len(got) != 5 {
t.Fatal("want", 5, "got", len(got))
}
s = "foobar"
got = Resize(s, 5)
if got != "fo..." {
t.Fatal("want", "fo...", "got", got)
}
}
func TestPadRight(t *testing.T) {
got := PadRight("foo", 5, '-')
if got != "foo--" {
t.Fatal("want", "foo--", "got", got)
}
}
func TestPadLeft(t *testing.T) {
got := PadLeft("foo", 5, '-')
if got != "--foo" {
t.Fatal("want", "--foo", "got", got)
}
}
func TestPrettyTime(t *testing.T) {
d, _ := time.ParseDuration("")
got := PrettyTime(d)
if got != "---" {
t.Fatal("want", "---", "got", got)
}
}
|