fabsf tests: More tests.
authorBruno Haible <bruno@clisp.org>
Sat, 25 Feb 2012 12:13:10 +0000 (13:13 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 25 Feb 2012 12:13:10 +0000 (13:13 +0100)
* tests/test-fabsf.c: Include <string.h>, minus-zero.h.
(zero): New variable.
(main): Add tests for signed zero.
* modules/fabsf-tests (Files): Add tests/minus-zero.h.

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

index caf179d..5c2590d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-02-25  Bruno Haible  <bruno@clisp.org>
+
+       fabsf tests: More tests.
+       * tests/test-fabsf.c: Include <string.h>, minus-zero.h.
+       (zero): New variable.
+       (main): Add tests for signed zero.
+       * modules/fabsf-tests (Files): Add tests/minus-zero.h.
+
 2012-02-24  Bruno Haible  <bruno@clisp.org>
 
        atanl: Provide function definition on MSVC.
index 2b8a10d..74ba723 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-fabsf.c
 tests/signature.h
+tests/minus-zero.h
 tests/macros.h
 
 Depends-on:
index d08625e..b78b801 100644 (file)
 #include "signature.h"
 SIGNATURE_CHECK (fabsf, float, (float));
 
+#include <string.h>
+
 #include "macros.h"
+#include "minus-zero.h"
 
 volatile float x;
 float y;
+float zero = 0.0f;
 
 int
 main ()
@@ -41,5 +45,16 @@ main ()
   y = fabsf (x);
   ASSERT (y == 0.6f);
 
+  /* Signed zero.  */
+  x = 0.0f;
+  y = fabsf (x);
+  ASSERT (y == 0.0f);
+  ASSERT (memcmp (&y, &zero, sizeof y) == 0);
+
+  x = minus_zerof;
+  y = fabsf (x);
+  ASSERT (y == 0.0f);
+  ASSERT (memcmp (&y, &zero, sizeof y) == 0);
+
   return 0;
 }