From: Bruno Haible Date: Sat, 25 Feb 2012 12:13:59 +0000 (+0100) Subject: fabs tests: More tests. X-Git-Tag: v0.1~1122 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=9175ae232830f814b8d6ad2450f58161fe7d6836;p=gnulib.git fabs tests: More tests. * tests/test-fabs.c: Include , minus-zero.h. (zero): New variable. (main): Add tests for signed zero. * modules/fabs-tests (Files): Add tests/minus-zero.h. --- diff --git a/ChangeLog b/ChangeLog index 5c2590d3a..3d40c0cc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2012-02-25 Bruno Haible + fabs tests: More tests. + * tests/test-fabs.c: Include , 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 , minus-zero.h. (zero): New variable. diff --git a/modules/fabs-tests b/modules/fabs-tests index b71615918..3d879bf61 100644 --- 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: diff --git a/tests/test-fabs.c b/tests/test-fabs.c index 81c5c7d49..4533441f5 100644 --- a/tests/test-fabs.c +++ b/tests/test-fabs.c @@ -23,10 +23,14 @@ #include "signature.h" SIGNATURE_CHECK (fabs, double, (double)); +#include + #include "macros.h" +#include "minus-zero.h" volatile double x; double y; +double zero = 0.0; int main () @@ -41,5 +45,16 @@ main () 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; }