Mercurial > hg > octave-lojdl > gnulib-hg
changeset 16441:2e6429c58643
Refactor frexp*-ieee tests.
* tests/test-frexp-ieee.h: New file.
* tests/test-frexpf-ieee.c: Include test-frexp-ieee.h.
(main): Just call test_function.
* tests/test-frexp-ieee.c: Include test-frexp-ieee.h.
(main): Just call test_function.
* tests/test-frexpl-ieee.c: Include test-frexp-ieee.h.
(main): Just call test_function.
* modules/frexpf-ieee-tests (Files): Add tests/test-frexp-ieee.h.
* modules/frexp-ieee-tests (Files): Likewise.
* modules/frexpl-ieee-tests (Files): Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 26 Feb 2012 16:19:59 +0100 |
parents | 43b148942038 |
children | 4d40d9e95523 |
files | ChangeLog modules/frexp-ieee-tests modules/frexpf-ieee-tests modules/frexpl-ieee-tests tests/test-frexp-ieee.c tests/test-frexp-ieee.h tests/test-frexpf-ieee.c tests/test-frexpl-ieee.c |
diffstat | 8 files changed, 115 insertions(+), 123 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2012-02-26 Bruno Haible <bruno@clisp.org> + Refactor frexp*-ieee tests. + * tests/test-frexp-ieee.h: New file. + * tests/test-frexpf-ieee.c: Include test-frexp-ieee.h. + (main): Just call test_function. + * tests/test-frexp-ieee.c: Include test-frexp-ieee.h. + (main): Just call test_function. + * tests/test-frexpl-ieee.c: Include test-frexp-ieee.h. + (main): Just call test_function. + * modules/frexpf-ieee-tests (Files): Add tests/test-frexp-ieee.h. + * modules/frexp-ieee-tests (Files): Likewise. + * modules/frexpl-ieee-tests (Files): Likewise. + Tests for module 'frexpl-ieee'. * modules/frexpl-ieee-tests: New file. * tests/test-frexpl-ieee.c: New file.
--- a/modules/frexp-ieee-tests +++ b/modules/frexp-ieee-tests @@ -1,5 +1,6 @@ Files: tests/test-frexp-ieee.c +tests/test-frexp-ieee.h tests/minus-zero.h tests/infinity.h tests/nan.h
--- a/modules/frexpf-ieee-tests +++ b/modules/frexpf-ieee-tests @@ -1,5 +1,6 @@ Files: tests/test-frexpf-ieee.c +tests/test-frexp-ieee.h tests/minus-zero.h tests/infinity.h tests/nan.h
--- a/modules/frexpl-ieee-tests +++ b/modules/frexpl-ieee-tests @@ -1,5 +1,6 @@ Files: tests/test-frexpl-ieee.c +tests/test-frexp-ieee.h tests/minus-zero.h tests/infinity.h tests/nan.h
--- a/tests/test-frexp-ieee.c +++ b/tests/test-frexp-ieee.c @@ -24,50 +24,22 @@ #include "nan.h" #include "macros.h" +#undef INFINITY +#undef NAN + +#define DOUBLE double +#define ISNAN isnand +#define INFINITY Infinityd () +#define NAN NaNd () +#define L_(literal) literal +#define MINUS_ZERO minus_zerod +#define FREXP frexp +#include "test-frexp-ieee.h" + int main () { - /* [MX] shaded specification in POSIX. */ - - /* NaN. */ - { - int exp = -9999; - double mantissa; - mantissa = frexp (NaNd (), &exp); - ASSERT (isnand (mantissa)); - } - - /* Signed zero. */ - { - int exp = -9999; - double mantissa; - mantissa = frexp (0.0, &exp); - ASSERT (mantissa == 0.0); - ASSERT (!signbit (mantissa)); - ASSERT (exp == 0); - } - { - int exp = -9999; - double mantissa; - mantissa = frexp (minus_zerod, &exp); - ASSERT (mantissa == 0.0); - ASSERT (!!signbit (mantissa) == !!signbit (minus_zerod)); - ASSERT (exp == 0); - } - - /* Infinity. */ - { - int exp = -9999; - double mantissa; - mantissa = frexp (Infinityd (), &exp); - ASSERT (mantissa == Infinityd ()); - } - { - int exp = -9999; - double mantissa; - mantissa = frexp (- Infinityd (), &exp); - ASSERT (mantissa == - Infinityd ()); - } + test_function (); return 0; }
new file mode 100644 --- /dev/null +++ b/tests/test-frexp-ieee.h @@ -0,0 +1,61 @@ +/* Test of splitting a double into fraction and mantissa. + Copyright (C) 2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +static void +test_function (void) +{ + /* [MX] shaded specification in POSIX. */ + + /* NaN. */ + { + int exp = -9999; + DOUBLE mantissa; + mantissa = FREXP (NAN, &exp); + ASSERT (ISNAN (mantissa)); + } + + /* Signed zero. */ + { + int exp = -9999; + DOUBLE mantissa; + mantissa = FREXP (L_(0.0), &exp); + ASSERT (mantissa == L_(0.0)); + ASSERT (!signbit (mantissa)); + ASSERT (exp == 0); + } + { + int exp = -9999; + DOUBLE mantissa; + mantissa = FREXP (MINUS_ZERO, &exp); + ASSERT (mantissa == L_(0.0)); + ASSERT (!!signbit (mantissa) == !!signbit (MINUS_ZERO)); + ASSERT (exp == 0); + } + + /* Infinity. */ + { + int exp = -9999; + DOUBLE mantissa; + mantissa = FREXP (INFINITY, &exp); + ASSERT (mantissa == INFINITY); + } + { + int exp = -9999; + DOUBLE mantissa; + mantissa = FREXP (- INFINITY, &exp); + ASSERT (mantissa == - INFINITY); + } +}
--- a/tests/test-frexpf-ieee.c +++ b/tests/test-frexpf-ieee.c @@ -24,50 +24,22 @@ #include "nan.h" #include "macros.h" +#undef INFINITY +#undef NAN + +#define DOUBLE float +#define ISNAN isnanf +#define INFINITY Infinityf () +#define NAN NaNf () +#define L_(literal) literal##f +#define MINUS_ZERO minus_zerof +#define FREXP frexpf +#include "test-frexp-ieee.h" + int main () { - /* [MX] shaded specification in POSIX. */ - - /* NaN. */ - { - int exp = -9999; - float mantissa; - mantissa = frexpf (NaNf (), &exp); - ASSERT (isnanf (mantissa)); - } - - /* Signed zero. */ - { - int exp = -9999; - float mantissa; - mantissa = frexpf (0.0f, &exp); - ASSERT (mantissa == 0.0f); - ASSERT (!signbit (mantissa)); - ASSERT (exp == 0); - } - { - int exp = -9999; - float mantissa; - mantissa = frexpf (minus_zerof, &exp); - ASSERT (mantissa == 0.0f); - ASSERT (!!signbit (mantissa) == !!signbit (minus_zerof)); - ASSERT (exp == 0); - } - - /* Infinity. */ - { - int exp = -9999; - float mantissa; - mantissa = frexpf (Infinityf (), &exp); - ASSERT (mantissa == Infinityf ()); - } - { - int exp = -9999; - float mantissa; - mantissa = frexpf (- Infinityf (), &exp); - ASSERT (mantissa == - Infinityf ()); - } + test_function (); return 0; }
--- a/tests/test-frexpl-ieee.c +++ b/tests/test-frexpl-ieee.c @@ -24,50 +24,22 @@ #include "nan.h" #include "macros.h" +#undef INFINITY +#undef NAN + +#define DOUBLE long double +#define ISNAN isnanl +#define INFINITY Infinityl () +#define NAN NaNl () +#define L_(literal) literal##L +#define MINUS_ZERO minus_zerol +#define FREXP frexpl +#include "test-frexp-ieee.h" + int main () { - /* [MX] shaded specification in POSIX. */ - - /* NaN. */ - { - int exp = -9999; - long double mantissa; - mantissa = frexpl (NaNl (), &exp); - ASSERT (isnanl (mantissa)); - } - - /* Signed zero. */ - { - int exp = -9999; - long double mantissa; - mantissa = frexpl (0.0L, &exp); - ASSERT (mantissa == 0.0L); - ASSERT (!signbit (mantissa)); - ASSERT (exp == 0); - } - { - int exp = -9999; - long double mantissa; - mantissa = frexpl (minus_zerol, &exp); - ASSERT (mantissa == 0.0L); - ASSERT (!!signbit (mantissa) == !!signbit (minus_zerol)); - ASSERT (exp == 0); - } - - /* Infinity. */ - { - int exp = -9999; - long double mantissa; - mantissa = frexpl (Infinityl (), &exp); - ASSERT (mantissa == Infinityl ()); - } - { - int exp = -9999; - long double mantissa; - mantissa = frexpl (- Infinityl (), &exp); - ASSERT (mantissa == - Infinityl ()); - } + test_function (); return 0; }