]> Cypherpunks repositories - gostls13.git/commit
time: fix quickcheck test to avoid wraparounds
authorRuss Cox <rsc@golang.org>
Mon, 25 Apr 2022 18:06:10 +0000 (14:06 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 26 Apr 2022 02:28:58 +0000 (02:28 +0000)
commit17d7983b29ba633708a9d7b18f90ab5bc029502d
tree37a2799a2c7955a770fa5eb73435f031b6a863a3
parent09ada1af8f54584e46deb0d643713393a9d83b10
time: fix quickcheck test to avoid wraparounds

When we call time.Unix(s, ns), the internal representation is
s + 62135596800,  where 62135596800 is the number of
seconds from Jan 1 1 to Jan 1 1970.

If quickcheck generates numbers too close to 2^63,
the addition can wraparound to make a very negative
internal 64-bit value. Wraparounds are not guarded
against, since they would not arise in any reasonable program,
so just avoid testing near them.

Fixes #52409.

Change-Id: Id466c8a34a49055ab26f2687a6b2b657cb64bed6
Reviewed-on: https://go-review.googlesource.com/c/go/+/402177
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/time/time_test.go