1
0
mirror of https://github.com/golang/go synced 2024-09-25 15:10:11 -06:00

math: test for pos/neg zero return of Ceil/Floor/Trunc

Ceil and Trunc of -0.2 return -0, not +0, but we didn't test that.

Updates #23647

Change-Id: Idbd4699376abfb4ca93f16c73c114d610d86a9f2
Reviewed-on: https://go-review.googlesource.com/91335
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Ian Lance Taylor 2018-01-31 20:40:34 -08:00
parent aa311fecda
commit 1ae2eed0b2

View File

@ -128,7 +128,7 @@ var cbrt = []float64{
var ceil = []float64{
5.0000000000000000e+00,
8.0000000000000000e+00,
0.0000000000000000e+00,
Copysign(0, -1),
-5.0000000000000000e+00,
1.0000000000000000e+01,
3.0000000000000000e+00,
@ -644,7 +644,7 @@ var tanh = []float64{
var trunc = []float64{
4.0000000000000000e+00,
7.0000000000000000e+00,
-0.0000000000000000e+00,
Copysign(0, -1),
-5.0000000000000000e+00,
9.0000000000000000e+00,
2.0000000000000000e+00,
@ -2158,7 +2158,7 @@ func TestCbrt(t *testing.T) {
func TestCeil(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := Ceil(vf[i]); ceil[i] != f {
if f := Ceil(vf[i]); !alike(ceil[i], f) {
t.Errorf("Ceil(%g) = %g, want %g", vf[i], f, ceil[i])
}
}
@ -2385,7 +2385,7 @@ func TestDim(t *testing.T) {
func TestFloor(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := Floor(vf[i]); floor[i] != f {
if f := Floor(vf[i]); !alike(floor[i], f) {
t.Errorf("Floor(%g) = %g, want %g", vf[i], f, floor[i])
}
}
@ -2916,7 +2916,7 @@ func TestTanh(t *testing.T) {
func TestTrunc(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := Trunc(vf[i]); trunc[i] != f {
if f := Trunc(vf[i]); !alike(trunc[i], f) {
t.Errorf("Trunc(%g) = %g, want %g", vf[i], f, trunc[i])
}
}