mirror of
https://github.com/golang/go
synced 2024-11-17 03:14:50 -07:00
math: test large negative values as args for trig functions
Sin/Tan are odd, Cos is even, so it is easy to compute the correct result from the positive argument case. Change-Id: If851d00fc7f515ece8199cf56d21186ced51e94f Reviewed-on: https://go-review.googlesource.com/c/go/+/509815 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Srinivas Pokala <Pokala.Srinivas@ibm.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Keith Randall <khr@google.com>
This commit is contained in:
parent
229cde5149
commit
9b33543339
@ -81,6 +81,10 @@ func TestHugeCos(t *testing.T) {
|
|||||||
if !close(f1, f2) {
|
if !close(f1, f2) {
|
||||||
t.Errorf("Cos(%g) = %g, want %g", trigHuge[i], f2, f1)
|
t.Errorf("Cos(%g) = %g, want %g", trigHuge[i], f2, f1)
|
||||||
}
|
}
|
||||||
|
f3 := Cos(-trigHuge[i])
|
||||||
|
if !close(f1, f3) {
|
||||||
|
t.Errorf("Cos(%g) = %g, want %g", -trigHuge[i], f3, f1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +95,10 @@ func TestHugeSin(t *testing.T) {
|
|||||||
if !close(f1, f2) {
|
if !close(f1, f2) {
|
||||||
t.Errorf("Sin(%g) = %g, want %g", trigHuge[i], f2, f1)
|
t.Errorf("Sin(%g) = %g, want %g", trigHuge[i], f2, f1)
|
||||||
}
|
}
|
||||||
|
f3 := Sin(-trigHuge[i])
|
||||||
|
if !close(-f1, f3) {
|
||||||
|
t.Errorf("Sin(%g) = %g, want %g", -trigHuge[i], f3, -f1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +109,10 @@ func TestHugeSinCos(t *testing.T) {
|
|||||||
if !close(f1, f2) || !close(g1, g2) {
|
if !close(f1, f2) || !close(g1, g2) {
|
||||||
t.Errorf("Sincos(%g) = %g, %g, want %g, %g", trigHuge[i], f2, g2, f1, g1)
|
t.Errorf("Sincos(%g) = %g, %g, want %g, %g", trigHuge[i], f2, g2, f1, g1)
|
||||||
}
|
}
|
||||||
|
f3, g3 := Sincos(-trigHuge[i])
|
||||||
|
if !close(-f1, f3) || !close(g1, g3) {
|
||||||
|
t.Errorf("Sincos(%g) = %g, %g, want %g, %g", -trigHuge[i], f3, g3, -f1, g1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,5 +123,9 @@ func TestHugeTan(t *testing.T) {
|
|||||||
if !close(f1, f2) {
|
if !close(f1, f2) {
|
||||||
t.Errorf("Tan(%g) = %g, want %g", trigHuge[i], f2, f1)
|
t.Errorf("Tan(%g) = %g, want %g", trigHuge[i], f2, f1)
|
||||||
}
|
}
|
||||||
|
f3 := Tan(-trigHuge[i])
|
||||||
|
if !close(-f1, f3) {
|
||||||
|
t.Errorf("Tan(%g) = %g, want %g", -trigHuge[i], f3, -f1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user