-
Notifications
You must be signed in to change notification settings - Fork 42
/
time_test.go
31 lines (28 loc) · 858 Bytes
/
time_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
package fit
import (
"testing"
"time"
)
var timeTests = []struct {
secs uint32
time time.Time
}{
{0, time.Date(1989, time.December, 31, 0, 0, 0, 0, time.UTC)},
{1, time.Date(1989, time.December, 31, 0, 0, 1, 0, time.UTC)},
{60 * 60 * 24, time.Date(1990, time.January, 1, 0, 0, 0, 0, time.UTC)},
{172800, time.Date(1990, time.January, 2, 0, 0, 0, 0, time.UTC)},
{14515200, time.Date(1990, time.June, 17, 0, 0, 0, 0, time.UTC)},
{771897600, time.Date(2014, time.June, 17, 0, 0, 0, 0, time.UTC)},
}
func TestDateTimeEncDec(t *testing.T) {
for i, tt := range timeTests {
decGot := decodeDateTime(tt.secs)
if decGot != tt.time {
t.Errorf("%d: want %v from DecodeDateTime, got %v", i, tt.time, decGot)
}
encGot := encodeTime(tt.time)
if encGot != tt.secs {
t.Errorf("%d: want %v from EncodeTime, got %v", i, tt.secs, encGot)
}
}
}