summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-02-29 12:32:18 +0100
committerBruno Haible <bruno@clisp.org>2012-02-29 12:32:18 +0100
commit260aec2c20bc33e0a8117efe9435939caded3747 (patch)
tree3c4c1bc532b2d5dc3fed6dba6ac278365e7f3ff5
parent99bd612913ce8770196ac6296288b038c5f2ea7e (diff)
downloadgnulib-260aec2c20bc33e0a8117efe9435939caded3747.tar.gz
hypot tests: More tests.
* tests/test-hypot.c: Include <float.h>. (main): Add tests about overflow and underflow.
-rw-r--r--ChangeLog6
-rw-r--r--tests/test-hypot.c20
2 files changed, 26 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b418b2c492..18647d66c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2012-02-29 Bruno Haible <bruno@clisp.org>
+ hypot tests: More tests.
+ * tests/test-hypot.c: Include <float.h>.
+ (main): Add tests about overflow and underflow.
+
+2012-02-29 Bruno Haible <bruno@clisp.org>
+
math code: Add comments.
* lib/acosl.c: Add comment about related glibc source files.
* lib/asinl.c: Likewise.
diff --git a/tests/test-hypot.c b/tests/test-hypot.c
index ca762d17a8..d8cf7faaff 100644
--- a/tests/test-hypot.c
+++ b/tests/test-hypot.c
@@ -23,6 +23,8 @@
#include "signature.h"
SIGNATURE_CHECK (hypot, double, (double, double));
+#include <float.h>
+
#include "macros.h"
volatile double x;
@@ -38,5 +40,23 @@ main ()
z = hypot (x, y);
ASSERT (z >= 0.7211102550 && z <= 0.7211102551);
+ /* Overflow. */
+ x = DBL_MAX;
+ y = DBL_MAX * 0.5;
+ z = hypot (x, y);
+ ASSERT (z == HUGE_VAL);
+
+ /* No underflow. */
+ x = DBL_MIN;
+ y = 0.0;
+ z = hypot (x, y);
+ ASSERT (z == DBL_MIN);
+
+ /* No underflow. */
+ x = DBL_MIN * 2.0;
+ y = DBL_MIN * 3.0;
+ z = hypot (x, y);
+ ASSERT (z >= DBL_MIN * 2.0 && z <= DBL_MIN * 4.0);
+
return 0;
}