Since "m" could stand for both "minute" and "month", and months vary in length, let's stop at days.
This commit is contained in:
17
acid_test.go
17
acid_test.go
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"testing"
|
||||
ttemplate "text/template"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestTemplateQuote(t *testing.T) {
|
||||
@@ -30,3 +31,19 @@ func TestTemplateQuote(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortDurationString(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
d time.Duration
|
||||
expect string
|
||||
}{
|
||||
{72 * time.Hour, "3d"},
|
||||
{-3 * time.Hour, "-3h"},
|
||||
{12 * time.Minute, "12m"},
|
||||
{time.Millisecond, "0s"},
|
||||
} {
|
||||
if sd := shortDurationString(test.d); sd != test.expect {
|
||||
t.Errorf("%s = %s; want %s\n", test.d, sd, test.expect)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user