diff options
| author | Roland Shoemaker <roland@golang.org> | 2022-03-05 08:47:33 -0800 |
|---|---|---|
| committer | Roland Shoemaker <roland@golang.org> | 2022-03-07 15:02:48 +0000 |
| commit | 63bd6f68e6cbb237b46a99775103758afaee370a (patch) | |
| tree | 24df61cbb877e95218e9e405ebdd1c222ff3a588 /src/internal/fuzz/encoding_test.go | |
| parent | d1820f748f8d63da8ef602e53d1db224f072be8f (diff) | |
| download | go-63bd6f68e6cbb237b46a99775103758afaee370a.tar.xz | |
internal/fuzz: fix TestUnmarshalMarshal on MIPS
Previous value used in the float32 roundtrip used float32(math.NaN())-1
which caused the quiet/signal bit to flip, which seemed to break the
test on MIPS platforms. Instead switch to using float32(math.NaN())+1,
which preserves the bit and makes the test happy.
Possibly related to #37455
Fixes #51258
Change-Id: Ia85c649e89a5d02027c0ec197f0ff318aa819c19
Reviewed-on: https://go-review.googlesource.com/c/go/+/390214
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/internal/fuzz/encoding_test.go')
| -rw-r--r-- | src/internal/fuzz/encoding_test.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/internal/fuzz/encoding_test.go b/src/internal/fuzz/encoding_test.go index 4b55892acd..3a614f5bd2 100644 --- a/src/internal/fuzz/encoding_test.go +++ b/src/internal/fuzz/encoding_test.go @@ -104,6 +104,12 @@ float32(2.5)`, ok: true, }, { + // The two IEEE 754 bit patterns used for the math.Float{64,32}frombits + // encodings are non-math.NAN quiet-NaN values. Since they are not equal + // to math.NaN(), they should be re-encoded to their bit patterns. They + // are, respectively: + // * math.Float64bits(math.NaN())+1 + // * math.Float32bits(float32(math.NaN()))+1 in: `go test fuzz v1 float32(-0) float64(-0) @@ -113,8 +119,8 @@ float32(NaN) float64(+Inf) float64(-Inf) float64(NaN) -math.Float64frombits(9221120237041090560) -math.Float32frombits(2143289343)`, +math.Float64frombits(9221120237041090562) +math.Float32frombits(2143289345)`, ok: true, }, } |
