Mercurial > hg > octave-lyh > gnulib-hg
changeset 16512:81d88046c46b
hypot tests: More tests.
* tests/test-hypot.c: Include <float.h>.
(main): Add tests about overflow and underflow.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 29 Feb 2012 12:32:18 +0100 |
parents | 2074f2bf7216 |
children | f42c8eb008b8 |
files | ChangeLog tests/test-hypot.c |
diffstat | 2 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +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.
--- 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 @@ 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; }