@@ -18,6 +18,7 @@ func TestTimeMarshalJSON(t *testing.T) {
18
18
{jwt.Time {}, 0 },
19
19
{jwt.Time {now }, now .Unix ()},
20
20
{jwt.Time {now .Add (24 * time .Hour )}, now .Add (24 * time .Hour ).Unix ()},
21
+ {jwt.Time {now .Add (24 * 30 * 12 * time .Hour )}, now .Add (24 * 30 * 12 * time .Hour ).Unix ()},
21
22
}
22
23
for _ , tc := range testCases {
23
24
t .Run ("" , func (t * testing.T ) {
@@ -39,17 +40,23 @@ func TestTimeMarshalJSON(t *testing.T) {
39
40
func TestTimeUnmarshalJSON (t * testing.T ) {
40
41
now := time .Now ()
41
42
testCases := []struct {
42
- n int64
43
- want jwt.Time
43
+ n int64
44
+ want jwt.Time
45
+ isNil bool
44
46
}{
45
- {now .Unix (), jwt.Time {now }},
46
- {internal .Epoch .Unix () - 1337 , jwt.Time {}},
47
- {internal .Epoch .Unix (), jwt.Time {}},
48
- {internal .Epoch .Unix () + 1337 , jwt.Time {internal .Epoch .Add (1337 * time .Second )}},
47
+ {now .Unix (), jwt.Time {now }, false },
48
+ {internal .Epoch .Unix () - 1337 , jwt.Time {internal .Epoch }, false },
49
+ {internal .Epoch .Unix (), jwt.Time {internal .Epoch }, false },
50
+ {internal .Epoch .Unix () + 1337 , jwt.Time {internal .Epoch .Add (1337 * time .Second )}, false },
51
+ {0 , jwt.Time {}, true },
49
52
}
50
53
for _ , tc := range testCases {
51
54
t .Run ("" , func (t * testing.T ) {
52
- b , err := json .Marshal (tc .n )
55
+ var n * int64
56
+ if ! tc .isNil {
57
+ n = & tc .n
58
+ }
59
+ b , err := json .Marshal (n )
53
60
if err != nil {
54
61
t .Fatal (err )
55
62
}
0 commit comments