aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2023-07-14 08:34:39 -0700
committerKeith Randall <khr@google.com>2023-07-17 21:05:34 +0000
commit9b335433396088d2701e8a058ae107689404ec6a (patch)
treeba1d1f1633d708dba134e4fdb5d871c0de8abc58
parent229cde5149fb30b5207c03e7ad296d9dbe027e66 (diff)
downloadgo-9b335433396088d2701e8a058ae107689404ec6a.tar.gz
go-9b335433396088d2701e8a058ae107689404ec6a.zip
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>
-rw-r--r--src/math/huge_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/math/huge_test.go b/src/math/huge_test.go
index bc28c6ff69..568b0c85eb 100644
--- a/src/math/huge_test.go
+++ b/src/math/huge_test.go
@@ -81,6 +81,10 @@ func TestHugeCos(t *testing.T) {
if !close(f1, f2) {
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) {
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) {
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) {
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)
+ }
}
}