Skip to content

Commit 3d5a7f0

Browse files
author
Matthew
committed
tests(time): add unit tests
1 parent 3cf2b68 commit 3d5a7f0

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

time/time_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package time
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestUnMarshalText(t *testing.T) {
8+
dummyTime := Time{}
9+
10+
goodTimeFormats := []string{
11+
"2006-01-02T15:04:05MST",
12+
"2006-01-02T15:04:05",
13+
}
14+
for _, goodTime := range goodTimeFormats {
15+
if dummyTime.UnmarshalText([]byte(goodTime)) != nil {
16+
t.Error("expected " + goodTime + " to be marshal-able.")
17+
}
18+
}
19+
20+
badTime := "this is a bad time, isn't it?"
21+
if dummyTime.UnmarshalText([]byte(badTime)) == nil {
22+
t.Error("expected " + badTime + "to be unmarshal-able.")
23+
}
24+
}

0 commit comments

Comments
 (0)