From: Bruno Haible Date: Sat, 3 Mar 2012 13:28:03 +0000 (+0100) Subject: frexp* tests: More tests. X-Git-Tag: v0.1~967 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=a4450a07cbf1fdca6dab512323d6f1ff5cdf21f8;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 1fc01f4260..ceef59be6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2012-03-03 Bruno Haible + + 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 Support for pseudo-random numbers in tests. diff --git a/modules/frexp-tests b/modules/frexp-tests index 3b3b837c64..0d957f28c0 100644 --- a/modules/frexp-tests +++ b/modules/frexp-tests @@ -6,6 +6,7 @@ tests/infinity.h tests/nan.h tests/signature.h tests/macros.h +tests/randomd.c Depends-on: isnand-nolibm @@ -16,4 +17,5 @@ configure.ac: Makefile.am: TESTS += test-frexp check_PROGRAMS += test-frexp +test_frexp_SOURCES = test-frexp.c randomd.c test_frexp_LDADD = $(LDADD) @FREXP_LIBM@ diff --git a/modules/frexpf-tests b/modules/frexpf-tests index 2efb31a8f1..c7bfbed6c1 100644 --- a/modules/frexpf-tests +++ b/modules/frexpf-tests @@ -6,6 +6,7 @@ tests/infinity.h tests/nan.h tests/signature.h tests/macros.h +tests/randomf.c Depends-on: isnanf-nolibm @@ -16,4 +17,5 @@ configure.ac: Makefile.am: TESTS += test-frexpf check_PROGRAMS += test-frexpf +test_frexpf_SOURCES = test-frexpf.c randomf.c test_frexpf_LDADD = $(LDADD) @FREXPF_LIBM@ diff --git a/modules/frexpl-tests b/modules/frexpl-tests index ee9f4c5fb8..2c0f99ed1b 100644 --- a/modules/frexpl-tests +++ b/modules/frexpl-tests @@ -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-frexpl check_PROGRAMS += test-frexpl +test_frexpl_SOURCES = test-frexpl.c randoml.c test_frexpl_LDADD = $(LDADD) @FREXPL_LIBM@ diff --git a/tests/test-frexp.c b/tests/test-frexp.c index 0065af358a..2b6a9fbf1e 100644 --- a/tests/test-frexp.c +++ b/tests/test-frexp.c @@ -55,6 +55,7 @@ SIGNATURE_CHECK (frexp, double, (double, int *)); #define MIN_EXP DBL_MIN_EXP #define MIN_NORMAL_EXP DBL_MIN_EXP #define FREXP frexp +#define RANDOM randomd #include "test-frexp.h" int diff --git a/tests/test-frexp.h b/tests/test-frexp.h index 3ea52b9746..71001df423 100644 --- a/tests/test-frexp.h +++ b/tests/test-frexp.h @@ -165,4 +165,15 @@ test_function (void) 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)); + } + } } diff --git a/tests/test-frexpf.c b/tests/test-frexpf.c index fa469284bb..b879c00788 100644 --- a/tests/test-frexpf.c +++ b/tests/test-frexpf.c @@ -50,6 +50,7 @@ SIGNATURE_CHECK (frexpf, float, (float, int *)); #define MIN_EXP FLT_MIN_EXP #define MIN_NORMAL_EXP FLT_MIN_EXP #define FREXP frexpf +#define RANDOM randomf #include "test-frexp.h" int diff --git a/tests/test-frexpl.c b/tests/test-frexpl.c index b46cb2ae1d..c5e07b256a 100644 --- a/tests/test-frexpl.c +++ b/tests/test-frexpl.c @@ -62,6 +62,7 @@ SIGNATURE_CHECK (frexpl, long double, (long double, int *)); # define MIN_NORMAL_EXP LDBL_MIN_EXP #endif #define FREXP frexpl +#define RANDOM randoml #include "test-frexp.h" int