changeset 16559:b576f9917ed1

frexp* tests: More tests. * tests/test-frexp.h (test_function): Add some pseudo-randomized tests. * tests/test-frexp.c (RANDOM): New macro. * tests/test-frexpf.c (RANDOM): New macro. * tests/test-frexpl.c (RANDOM): New macro. * modules/frexp-tests (Files): Add tests/randomd.c. (Makefile.am): Add randomd.c to test_frexp_SOURCES. * modules/frexpf-tests (Files): Add tests/randomf.c. (Makefile.am): Add randomf.c to test_frexpf_SOURCES. * modules/frexpl-tests (Files): Add tests/randoml.c. (Makefile.am): Add randoml.c to test_frexpl_SOURCES.
author Bruno Haible <bruno@clisp.org>
date Sat, 03 Mar 2012 14:28:03 +0100
parents 74e0aeb8a7cc
children f56ad1ce5e9e
files ChangeLog modules/frexp-tests modules/frexpf-tests modules/frexpl-tests tests/test-frexp.c tests/test-frexp.h tests/test-frexpf.c tests/test-frexpl.c
diffstat 8 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-03-03  Bruno Haible  <bruno@clisp.org>
+
+	frexp* tests: More tests.
+	* tests/test-frexp.h (test_function): Add some pseudo-randomized tests.
+	* tests/test-frexp.c (RANDOM): New macro.
+	* tests/test-frexpf.c (RANDOM): New macro.
+	* tests/test-frexpl.c (RANDOM): New macro.
+	* modules/frexp-tests (Files): Add tests/randomd.c.
+	(Makefile.am): Add randomd.c to test_frexp_SOURCES.
+	* modules/frexpf-tests (Files): Add tests/randomf.c.
+	(Makefile.am): Add randomf.c to test_frexpf_SOURCES.
+	* modules/frexpl-tests (Files): Add tests/randoml.c.
+	(Makefile.am): Add randoml.c to test_frexpl_SOURCES.
+
 2012-03-03  Bruno Haible  <bruno@clisp.org>
 
 	Support for pseudo-random numbers in tests.
--- a/modules/frexp-tests
+++ b/modules/frexp-tests
@@ -6,6 +6,7 @@
 tests/nan.h
 tests/signature.h
 tests/macros.h
+tests/randomd.c
 
 Depends-on:
 isnand-nolibm
@@ -16,4 +17,5 @@
 Makefile.am:
 TESTS += test-frexp
 check_PROGRAMS += test-frexp
+test_frexp_SOURCES = test-frexp.c randomd.c
 test_frexp_LDADD = $(LDADD) @FREXP_LIBM@
--- a/modules/frexpf-tests
+++ b/modules/frexpf-tests
@@ -6,6 +6,7 @@
 tests/nan.h
 tests/signature.h
 tests/macros.h
+tests/randomf.c
 
 Depends-on:
 isnanf-nolibm
@@ -16,4 +17,5 @@
 Makefile.am:
 TESTS += test-frexpf
 check_PROGRAMS += test-frexpf
+test_frexpf_SOURCES = test-frexpf.c randomf.c
 test_frexpf_LDADD = $(LDADD) @FREXPF_LIBM@
--- a/modules/frexpl-tests
+++ b/modules/frexpl-tests
@@ -6,6 +6,7 @@
 tests/nan.h
 tests/signature.h
 tests/macros.h
+tests/randoml.c
 
 Depends-on:
 fpucw
@@ -18,4 +19,5 @@
 Makefile.am:
 TESTS += test-frexpl
 check_PROGRAMS += test-frexpl
+test_frexpl_SOURCES = test-frexpl.c randoml.c
 test_frexpl_LDADD = $(LDADD) @FREXPL_LIBM@
--- a/tests/test-frexp.c
+++ b/tests/test-frexp.c
@@ -55,6 +55,7 @@
 #define MIN_EXP DBL_MIN_EXP
 #define MIN_NORMAL_EXP DBL_MIN_EXP
 #define FREXP frexp
+#define RANDOM randomd
 #include "test-frexp.h"
 
 int
--- a/tests/test-frexp.h
+++ b/tests/test-frexp.h
@@ -165,4 +165,15 @@
       ASSERT (mantissa < L_(1.0));
       ASSERT (mantissa == my_ldexp (x, - exp));
     }
+
+  /* Randomized tests.  */
+  for (i = 0; i < SIZEOF (RANDOM); i++)
+    {
+      x = L_(20.0) * RANDOM[i] - L_(10.0); /* -10.0 <= x <= 10.0 */
+      {
+        int exp = -9999;
+        DOUBLE mantissa = FREXP (x, &exp);
+        ASSERT (x == my_ldexp (mantissa, exp));
+      }
+    }
 }
--- a/tests/test-frexpf.c
+++ b/tests/test-frexpf.c
@@ -50,6 +50,7 @@
 #define MIN_EXP FLT_MIN_EXP
 #define MIN_NORMAL_EXP FLT_MIN_EXP
 #define FREXP frexpf
+#define RANDOM randomf
 #include "test-frexp.h"
 
 int
--- a/tests/test-frexpl.c
+++ b/tests/test-frexpl.c
@@ -62,6 +62,7 @@
 # define MIN_NORMAL_EXP LDBL_MIN_EXP
 #endif
 #define FREXP frexpl
+#define RANDOM randoml
 #include "test-frexp.h"
 
 int