You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
396 B
24 lines
396 B
package main |
|
|
|
import ( |
|
"testing" |
|
"time" |
|
) |
|
|
|
func TestParseDuration(t *testing.T) { |
|
d := parseDuration(" 45s") |
|
if d != (45 * time.Second) { |
|
t.Log(d) |
|
t.Fail() |
|
} |
|
d = parseDuration(" 10m 45s") |
|
if d != (45*time.Second)+(10*time.Minute) { |
|
t.Log(d) |
|
t.Fail() |
|
} |
|
d = parseDuration(" 12h 10m 45s") |
|
if d != (12*time.Hour)+(45*time.Second)+(10*time.Minute) { |
|
t.Log(d) |
|
t.Fail() |
|
} |
|
}
|
|
|