Mercurial > hg > octave-nkf > gnulib-hg
changeset 16675:801fab1c35f6
exp2* tests: More tests.
* tests/test-exp2.h (test_function): Test all integral arguments that
don't need to overflow or denormalized numbers.
* tests/test-exp2.c (MAX_EXP, MIN_EXP): New macros.
* tests/test-exp2f.c (MAX_EXP, MIN_EXP): Likewise.
* tests/test-exp2l.c (MAX_EXP, MIN_EXP): Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 11 Mar 2012 15:45:46 +0100 |
parents | 000ded1116ac |
children | e9598f93f892 |
files | ChangeLog tests/test-exp2.c tests/test-exp2.h tests/test-exp2f.c tests/test-exp2l.c |
diffstat | 5 files changed, 40 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-03-11 Bruno Haible <bruno@clisp.org> + + exp2* tests: More tests. + * tests/test-exp2.h (test_function): Test all integral arguments that + don't need to overflow or denormalized numbers. + * tests/test-exp2.c (MAX_EXP, MIN_EXP): New macros. + * tests/test-exp2f.c (MAX_EXP, MIN_EXP): Likewise. + * tests/test-exp2l.c (MAX_EXP, MIN_EXP): Likewise. + 2012-03-10 Bruno Haible <bruno@clisp.org> log1pl-ieee: Work around test failure on AIX 7.1.
--- a/tests/test-exp2.c +++ b/tests/test-exp2.c @@ -30,6 +30,8 @@ #define DOUBLE double #define L_(literal) literal #define MANT_DIG DBL_MANT_DIG +#define MAX_EXP DBL_MAX_EXP +#define MIN_EXP DBL_MIN_EXP #define EXP2 exp2 #define RANDOM randomd #include "test-exp2.h"
--- a/tests/test-exp2.h +++ b/tests/test-exp2.h @@ -29,45 +29,41 @@ * (DOUBLE) (1U << ((MANT_DIG - 1 + 3) / 5)) * (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5)); - /* Small integral arguments. */ + /* Integral arguments. */ { DOUBLE x = L_(0.0); DOUBLE y = EXP2 (x); ASSERT (y == L_(1.0)); } + /* <http://sourceware.org/bugzilla/show_bug.cgi?id=13824> */ +#if !(defined __linux__ && (defined __sparc__ || defined __powerpc__)) { - DOUBLE x = L_(1.0); - DOUBLE y = EXP2 (x); - ASSERT (y == L_(2.0)); + int e; + DOUBLE x; + DOUBLE y; + for (e = 0, x = L_(0.0), y = L_(1.0); + e <= MAX_EXP - 1; + e++, x = x + L_(1.0), y = y * L_(2.0)) + { + /* Invariant: x = e, y = 2^e. */ + DOUBLE z = EXP2 (x); + ASSERT (z == y); + } } { - DOUBLE x = L_(2.0); - DOUBLE y = EXP2 (x); - ASSERT (y == L_(4.0)); - } - /* <http://sourceware.org/bugzilla/show_bug.cgi?id=13824> */ -#if !(defined __linux__ && defined __sparc__) - { - DOUBLE x = L_(3.0); - DOUBLE y = EXP2 (x); - ASSERT (y == L_(8.0)); - } - { - DOUBLE x = L_(4.0); - DOUBLE y = EXP2 (x); - ASSERT (y == L_(16.0)); + int e; + DOUBLE x; + DOUBLE y; + for (e = 0, x = L_(0.0), y = L_(1.0); + e >= MIN_EXP - 1; + e--, x = x - L_(1.0), y = y * L_(0.5)) + { + /* Invariant: x = e, y = 2^e. */ + DOUBLE z = EXP2 (x); + ASSERT (z == y); + } } #endif - { - DOUBLE x = - L_(1.0); - DOUBLE y = EXP2 (x); - ASSERT (y == L_(0.5)); - } - { - DOUBLE x = - L_(2.0); - DOUBLE y = EXP2 (x); - ASSERT (y == L_(0.25)); - } /* Randomized tests. */ {