forked from wagslane/go-tinydate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_test.go
37 lines (29 loc) · 840 Bytes
/
create_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
32
33
34
35
36
37
package tinydate
import (
"testing"
)
func TestNew(t *testing.T) {
td, err := New(2020, 04, 3)
assertNil(t, err)
assertEqual(t, TinyDate{year: 2020, month: 3, day: 2}, td)
}
func TestNewManyMonths(t *testing.T) {
td, err := New(2020, 13, 3)
assertNil(t, err)
assertEqual(t, TinyDate{year: 2021, month: 0, day: 2}, td)
}
func TestNewManyDays(t *testing.T) {
td, err := New(2020, 1, 32)
assertNil(t, err)
assertEqual(t, TinyDate{year: 2020, month: 1, day: 0}, td)
}
func TestUnix(t *testing.T) {
td := Unix(1, 0)
assertEqual(t, TinyDate{year: 1970, month: 0, day: 0}, td)
td = Unix(86400, 0)
assertEqual(t, TinyDate{year: 1970, month: 0, day: 1}, td)
td = Unix(2678400, 0)
assertEqual(t, TinyDate{year: 1970, month: 1, day: 0}, td)
td = Unix(31536000, 0)
assertEqual(t, TinyDate{year: 1971, month: 0, day: 0}, td)
}