stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
23.55k stars 1.6k forks source link

Integer overflow in time.Time comparison #1581

Closed myxo closed 7 months ago

myxo commented 8 months ago

Description

time.Time comparison rely on https://pkg.go.dev/time#Time.UnixNano, but documentation explicitly said, that it has undefined behavior is data is bigger than year 2262 (since it not fit in int64)

Step To Reproduce

func TestTime(t *testing.T) {
    require.Less(t, time.Now(), time.Date(2263, 0, 0, 0, 0, 0, 0, time.Local))
}

Error: "2024-03-29 08:20:14.8719425 +0300 MSK m=+0.001135586" is not less than "2262-11-30 00:00:00 +0300 MSK"