From: Bruno Haible Date: Sat, 3 Mar 2012 13:59:07 +0000 (+0100) Subject: ldexp* tests: More tests. X-Git-Tag: v0.1~966 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=d9a34d524bf815ee9424bf43d8e069fd28a001c4;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index ceef59be6e..3f8a77c674 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2012-03-03 Bruno Haible + + 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 frexp* tests: More tests. diff --git a/modules/ldexp-tests b/modules/ldexp-tests index bd252cf505..2db1a43a97 100644 --- a/modules/ldexp-tests +++ b/modules/ldexp-tests @@ -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@ diff --git a/modules/ldexpf-tests b/modules/ldexpf-tests index 5de3203432..80ee90d6d6 100644 --- a/modules/ldexpf-tests +++ b/modules/ldexpf-tests @@ -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@ diff --git a/modules/ldexpl-tests b/modules/ldexpl-tests index 828143e446..c160d40686 100644 --- a/modules/ldexpl-tests +++ b/modules/ldexpl-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-ldexpl check_PROGRAMS += test-ldexpl +test_ldexpl_SOURCES = test-ldexpl.c randoml.c test_ldexpl_LDADD = $(LDADD) @LDEXPL_LIBM@ diff --git a/tests/test-ldexp.c b/tests/test-ldexp.c index 0890b61059..6e04e50829 100644 --- a/tests/test-ldexp.c +++ b/tests/test-ldexp.c @@ -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 diff --git a/tests/test-ldexp.h b/tests/test-ldexp.h index 76a095ee63..ef03a67702 100644 --- a/tests/test-ldexp.h +++ b/tests/test-ldexp.h @@ -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)); + } } diff --git a/tests/test-ldexpf.c b/tests/test-ldexpf.c index fece781374..0ee4917b40 100644 --- a/tests/test-ldexpf.c +++ b/tests/test-ldexpf.c @@ -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 diff --git a/tests/test-ldexpl.c b/tests/test-ldexpl.c index 80f740a5db..5fbe35664d 100644 --- a/tests/test-ldexpl.c +++ b/tests/test-ldexpl.c @@ -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