From: Bruno Haible Date: Wed, 29 Feb 2012 11:32:18 +0000 (+0100) Subject: hypot tests: More tests. X-Git-Tag: v0.1~1014 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=260aec2c20bc33e0a8117efe9435939caded3747;p=gnulib.git hypot tests: More tests. * tests/test-hypot.c: Include . (main): Add tests about overflow and underflow. --- diff --git a/ChangeLog b/ChangeLog index b418b2c492..18647d66c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-02-29 Bruno Haible + + hypot tests: More tests. + * tests/test-hypot.c: Include . + (main): Add tests about overflow and underflow. + 2012-02-29 Bruno Haible math code: Add comments. 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 + #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; }