]> Savannah Git Hosting - gnulib.git/commitdiff
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 5c2590d3af403f593e511904ad89b191b122d4fe..3d40c0cc22bda66c2954062e0f00eafb96110ac2 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 b716159182adafe4215dc870af5920d3eb0440e6..3d879bf61f23b38a187324fcbde69f8d95a3442d 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-fabs.c
 tests/signature.h
+tests/minus-zero.h
 tests/macros.h
 
 Depends-on:
index 81c5c7d498f9ab12174d543b88848336b9a7cd97..4533441f5957b6557da6489a937871a6cc4ad9fd 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;
 }