@@ -2,6 +2,7 @@ package jwt_test
22
33import (
44 "encoding/json"
5+ "math"
56 "testing"
67 "time"
78
@@ -79,23 +80,38 @@ func TestNumericDate_MarshalJSON(t *testing.T) {
7980 }{
8081 {time .Unix (5243700879 , 0 ), "5243700879" , time .Second },
8182 {time .Unix (5243700879 , 0 ), "5243700879.000" , time .Millisecond },
82- {time .Unix (5243700879 , 0 ), "5243700879.000001 " , time .Microsecond },
83- {time .Unix (5243700879 , 0 ), "5243700879.000000954 " , time .Nanosecond },
83+ {time .Unix (5243700879 , 0 ), "5243700879.000000 " , time .Microsecond },
84+ {time .Unix (5243700879 , 0 ), "5243700879.000000000 " , time .Nanosecond },
8485 //
8586 {time .Unix (4239425898 , 0 ), "4239425898" , time .Second },
8687 {time .Unix (4239425898 , 0 ), "4239425898.000" , time .Millisecond },
8788 {time .Unix (4239425898 , 0 ), "4239425898.000000" , time .Microsecond },
8889 {time .Unix (4239425898 , 0 ), "4239425898.000000000" , time .Nanosecond },
8990 //
91+ {time .Unix (253402271999 , 0 ), "253402271999" , time .Second },
92+ {time .Unix (253402271999 , 0 ), "253402271999.000" , time .Millisecond },
93+ {time .Unix (253402271999 , 0 ), "253402271999.000000" , time .Microsecond },
94+ {time .Unix (253402271999 , 0 ), "253402271999.000000000" , time .Nanosecond },
95+ //
9096 {time .Unix (0 , 1644285000210402000 ), "1644285000" , time .Second },
9197 {time .Unix (0 , 1644285000210402000 ), "1644285000.210" , time .Millisecond },
9298 {time .Unix (0 , 1644285000210402000 ), "1644285000.210402" , time .Microsecond },
93- {time .Unix (0 , 1644285000210402000 ), "1644285000.210402012 " , time .Nanosecond },
99+ {time .Unix (0 , 1644285000210402000 ), "1644285000.210402000 " , time .Nanosecond },
94100 //
95101 {time .Unix (0 , 1644285315063096000 ), "1644285315" , time .Second },
96102 {time .Unix (0 , 1644285315063096000 ), "1644285315.063" , time .Millisecond },
97103 {time .Unix (0 , 1644285315063096000 ), "1644285315.063096" , time .Microsecond },
98- {time .Unix (0 , 1644285315063096000 ), "1644285315.063096046" , time .Nanosecond },
104+ {time .Unix (0 , 1644285315063096000 ), "1644285315.063096000" , time .Nanosecond },
105+ // Maximum time that a go time.Time can represent
106+ {time .Unix (math .MaxInt64 , 999999999 ), "9223372036854775807" , time .Second },
107+ {time .Unix (math .MaxInt64 , 999999999 ), "9223372036854775807.999" , time .Millisecond },
108+ {time .Unix (math .MaxInt64 , 999999999 ), "9223372036854775807.999999" , time .Microsecond },
109+ {time .Unix (math .MaxInt64 , 999999999 ), "9223372036854775807.999999999" , time .Nanosecond },
110+ // Strange precisions
111+ {time .Unix (math .MaxInt64 , 999999999 ), "9223372036854775807" , time .Second },
112+ {time .Unix (math .MaxInt64 , 999999999 ), "9223372036854775756" , time .Minute },
113+ {time .Unix (math .MaxInt64 , 999999999 ), "9223372036854774016" , time .Hour },
114+ {time .Unix (math .MaxInt64 , 999999999 ), "9223372036854745216" , 24 * time .Hour },
99115 }
100116
101117 for i , tc := range tt {
0 commit comments