fabs tests: More tests.
authorBruno Haible <bruno@clisp.org>
Sat, 25 Feb 2012 12:13:59 +0000 (13:13 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 25 Feb 2012 12:13:59 +0000 (13:13 +0100)
* 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.

ChangeLog
modules/fabs-tests
tests/test-fabs.c

index 5c2590d..3d40c0c 100644 (file)
--- 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.
index b716159..3d879bf 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-fabs.c
 tests/signature.h
+tests/minus-zero.h
 tests/macros.h
 
 Depends-on:
index 81c5c7d..4533441 100644 (file)
 #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 @@ 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;
 }