Mercurial > hg > octave-shane > gnulib-hg
changeset 16404:fc64dbadc964
fabs tests: More tests.
* tests/test-fabs.c: Include <string.h>, minus-zero.h.
(zero): New variable.
(main): Add tests for signed zero.
* modules/fabs-tests (Files): Add tests/minus-zero.h.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 25 Feb 2012 13:13:59 +0100 |
parents | 580de3212c9d |
children | e393287b3d95 |
files | ChangeLog modules/fabs-tests tests/test-fabs.c |
diffstat | 3 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2012-02-25 Bruno Haible <bruno@clisp.org> + fabs tests: More tests. + * tests/test-fabs.c: Include <string.h>, minus-zero.h. + (zero): New variable. + (main): Add tests for signed zero. + * modules/fabs-tests (Files): Add tests/minus-zero.h. + fabsf tests: More tests. * tests/test-fabsf.c: Include <string.h>, minus-zero.h. (zero): New variable.
--- a/modules/fabs-tests +++ b/modules/fabs-tests @@ -1,6 +1,7 @@ Files: tests/test-fabs.c tests/signature.h +tests/minus-zero.h tests/macros.h Depends-on:
--- a/tests/test-fabs.c +++ b/tests/test-fabs.c @@ -23,10 +23,14 @@ #include "signature.h" SIGNATURE_CHECK (fabs, double, (double)); +#include <string.h> + #include "macros.h" +#include "minus-zero.h" volatile double x; double y; +double zero = 0.0; int main () @@ -41,5 +45,16 @@ y = fabs (x); ASSERT (y == 0.6); + /* Signed zero. */ + x = 0.0; + y = fabs (x); + ASSERT (y == 0.0); + ASSERT (memcmp (&y, &zero, sizeof y) == 0); + + x = minus_zerod; + y = fabs (x); + ASSERT (y == 0.0); + ASSERT (memcmp (&y, &zero, sizeof y) == 0); + return 0; }