]> Savannah Git Hosting - gnulib.git/commitdiff
ldexp* tests: More tests.
authorBruno Haible <bruno@clisp.org>
Sat, 3 Mar 2012 13:59:07 +0000 (14:59 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 3 Mar 2012 15:18:08 +0000 (16:18 +0100)
* tests/test-ldexp.h (test_function): Add some pseudo-randomized tests.
* tests/test-ldexp.c (RANDOM): New macro.
* tests/test-ldexpf.c (RANDOM): New macro.
* tests/test-ldexpl.c (RANDOM): New macro.
* modules/ldexp-tests (Files): Add tests/randomd.c.
(Makefile.am): Add randomd.c to test_ldexp_SOURCES.
* modules/ldexpf-tests (Files): Add tests/randomf.c.
(Makefile.am): Add randomf.c to test_ldexpf_SOURCES.
* modules/ldexpl-tests (Files): Add tests/randoml.c.
(Makefile.am): Add randoml.c to test_ldexpl_SOURCES.

ChangeLog
modules/ldexp-tests
modules/ldexpf-tests
modules/ldexpl-tests
tests/test-ldexp.c
tests/test-ldexp.h
tests/test-ldexpf.c
tests/test-ldexpl.c

index ceef59be6e7b4479f1e32dc3b2d914b964aa532a..3f8a77c6741fafca790375dcd2bb6ce6562d41a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-03-03  Bruno Haible  <bruno@clisp.org>
+
+       ldexp* tests: More tests.
+       * tests/test-ldexp.h (test_function): Add some pseudo-randomized tests.
+       * tests/test-ldexp.c (RANDOM): New macro.
+       * tests/test-ldexpf.c (RANDOM): New macro.
+       * tests/test-ldexpl.c (RANDOM): New macro.
+       * modules/ldexp-tests (Files): Add tests/randomd.c.
+       (Makefile.am): Add randomd.c to test_ldexp_SOURCES.
+       * modules/ldexpf-tests (Files): Add tests/randomf.c.
+       (Makefile.am): Add randomf.c to test_ldexpf_SOURCES.
+       * modules/ldexpl-tests (Files): Add tests/randoml.c.
+       (Makefile.am): Add randoml.c to test_ldexpl_SOURCES.
+
 2012-03-03  Bruno Haible  <bruno@clisp.org>
 
        frexp* tests: More tests.
index bd252cf505c308638b130bfde38bd5a02901f001..2db1a43a97fa51022d858373d76863756bd2463a 100644 (file)
@@ -6,6 +6,7 @@ tests/infinity.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
+tests/randomd.c
 
 Depends-on:
 isnand-nolibm
@@ -17,4 +18,5 @@ configure.ac:
 Makefile.am:
 TESTS += test-ldexp
 check_PROGRAMS += test-ldexp
+test_ldexp_SOURCES = test-ldexp.c randomd.c
 test_ldexp_LDADD = $(LDADD) @LDEXP_LIBM@
index 5de3203432ea393a97755242c51ac02149778907..80ee90d6d6a20b41db53406fbaeff49c6aeb8a93 100644 (file)
@@ -6,6 +6,7 @@ tests/infinity.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
+tests/randomf.c
 
 Depends-on:
 isnanf-nolibm
@@ -17,4 +18,5 @@ configure.ac:
 Makefile.am:
 TESTS += test-ldexpf
 check_PROGRAMS += test-ldexpf
+test_ldexpf_SOURCES = test-ldexpf.c randomf.c
 test_ldexpf_LDADD = $(LDADD) @LDEXPF_LIBM@
index 828143e44644a39a2c8b165c7cf5a6d3efccfe9f..c160d4068622ea88cadb476a2cbb0c35958b9076 100644 (file)
@@ -6,6 +6,7 @@ tests/infinity.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
+tests/randoml.c
 
 Depends-on:
 fpucw
@@ -18,4 +19,5 @@ configure.ac:
 Makefile.am:
 TESTS += test-ldexpl
 check_PROGRAMS += test-ldexpl
+test_ldexpl_SOURCES = test-ldexpl.c randoml.c
 test_ldexpl_LDADD = $(LDADD) @LDEXPL_LIBM@
index 0890b610592ef868f223546831e4f7c21be9d36b..6e04e50829f3a001f1e2ddc5cd2f9acf23398a54 100644 (file)
@@ -40,9 +40,10 @@ SIGNATURE_CHECK (ldexp, double, (double, int));
 #define NAN NaNd ()
 #define L_(literal) literal
 #define MINUS_ZERO minus_zerod
-#define LDEXP ldexp
 #define MIN_EXP DBL_MIN_EXP
 #define MAX_EXP DBL_MAX_EXP
+#define LDEXP ldexp
+#define RANDOM randomd
 #include "test-ldexp.h"
 
 int
index 76a095ee634ceefaadbf0988f9f900adee7a7550..ef03a677027897d8bc7a187608b0532841e2f48b 100644 (file)
@@ -114,4 +114,17 @@ test_function (void)
       y = LDEXP (x, 0); ASSERT (y == x);
       y = LDEXP (x, 5); ASSERT (y == x * L_(32.0));
     }
+
+  /* Randomized tests.  */
+  for (i = 0; i < SIZEOF (RANDOM); i++)
+    {
+      int u, v;
+
+      x = L_(20.0) * RANDOM[i] - L_(10.0); /* -10.0 <= x <= 10.0 */
+      /* LDEXP only does rounding when it returns a denormalized number
+         or there is underflow.  It doesn't happen here.  */
+      for (u = -10; u <= 10; u++)
+        for (v = -10; v <= 10; v++)
+          ASSERT (LDEXP (x, u + v) == LDEXP (LDEXP (x, u), v));
+    }
 }
index fece781374e45c4184d24457cb83d0d3f875a752..0ee4917b40ff9227ee2d0968fdc728480efac9b7 100644 (file)
@@ -40,9 +40,10 @@ SIGNATURE_CHECK (ldexpf, float, (float, int));
 #define NAN NaNf ()
 #define L_(literal) literal##f
 #define MINUS_ZERO minus_zerof
-#define LDEXP ldexpf
 #define MIN_EXP FLT_MIN_EXP
 #define MAX_EXP FLT_MAX_EXP
+#define LDEXP ldexpf
+#define RANDOM randomf
 #include "test-ldexp.h"
 
 int
index 80f740a5dbfe2b111d823e0280f5bed00f2de3a8..5fbe35664d88cf32e3e74bf339eb99ee911c9b9b 100644 (file)
@@ -41,9 +41,10 @@ SIGNATURE_CHECK (ldexpl, long double, (long double, int));
 #define NAN NaNl ()
 #define L_(literal) literal##L
 #define MINUS_ZERO minus_zerol
-#define LDEXP ldexpl
 #define MIN_EXP LDBL_MIN_EXP
 #define MAX_EXP LDBL_MAX_EXP
+#define LDEXP ldexpl
+#define RANDOM randoml
 #include "test-ldexp.h"
 
 int