Commit 24541cca authored by Bruno Haible's avatar Bruno Haible

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.
parent e300fea7
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.
Files:
tests/test-frexp-ieee.c
tests/test-frexp-ieee.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
......
Files:
tests/test-frexpf-ieee.c
tests/test-frexp-ieee.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
......
Files:
tests/test-frexpl-ieee.c
tests/test-frexp-ieee.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
......
......@@ -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;
}
/* 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);
}
}
......@@ -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;
}
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment