From f5e8d1d113d7767091266896f6dc5d5b2939b301 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 7 Mar 2012 00:39:56 +0100 Subject: [PATCH] Tests for module 'expm1-ieee'. * modules/expm1-ieee-tests: New file. * tests/test-expm1-ieee.c: New file. * tests/test-expm1-ieee.h: New file. --- ChangeLog | 5 +++++ modules/expm1-ieee-tests | 19 +++++++++++++++++++ tests/test-expm1-ieee.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/test-expm1-ieee.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 modules/expm1-ieee-tests create mode 100644 tests/test-expm1-ieee.c create mode 100644 tests/test-expm1-ieee.h diff --git a/ChangeLog b/ChangeLog index 56dd9fe3d..37344ac57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2012-03-06 Bruno Haible + Tests for module 'expm1-ieee'. + * modules/expm1-ieee-tests: New file. + * tests/test-expm1-ieee.c: New file. + * tests/test-expm1-ieee.h: New file. + New module 'expm1-ieee'. * modules/expm1-ieee: New file. * m4/expm1-ieee.m4: New file. diff --git a/modules/expm1-ieee-tests b/modules/expm1-ieee-tests new file mode 100644 index 000000000..4569a7b76 --- /dev/null +++ b/modules/expm1-ieee-tests @@ -0,0 +1,19 @@ +Files: +tests/test-expm1-ieee.c +tests/test-expm1-ieee.h +tests/minus-zero.h +tests/infinity.h +tests/nan.h +tests/macros.h + +Depends-on: +isnand-nolibm +float +signbit + +configure.ac: + +Makefile.am: +TESTS += test-expm1-ieee +check_PROGRAMS += test-expm1-ieee +test_expm1_ieee_LDADD = $(LDADD) @EXPM1_LIBM@ diff --git a/tests/test-expm1-ieee.c b/tests/test-expm1-ieee.c new file mode 100644 index 000000000..87dc9d289 --- /dev/null +++ b/tests/test-expm1-ieee.c @@ -0,0 +1,45 @@ +/* Test of expm1() function. + 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 . */ + +#include + +#include + +#include "isnand-nolibm.h" +#include "minus-zero.h" +#include "infinity.h" +#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 EXPM1 expm1 +#include "test-expm1-ieee.h" + +int +main () +{ + test_function (); + + return 0; +} diff --git a/tests/test-expm1-ieee.h b/tests/test-expm1-ieee.h new file mode 100644 index 000000000..fee764f01 --- /dev/null +++ b/tests/test-expm1-ieee.h @@ -0,0 +1,43 @@ +/* Test of expm1*() function family. + 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 . */ + +static void +test_function (void) +{ + /* [MX] shaded specification in POSIX. */ + + /* Underflow. */ + ASSERT (EXPM1 (-100000.0) == - L_(1.0)); + + /* NaN. */ + ASSERT (ISNAN (EXPM1 (NAN))); + + /* Zero. */ + { + DOUBLE z = EXPM1 (L_(0.0)); + ASSERT (z == L_(0.0)); + ASSERT (!signbit (z)); + } + { + DOUBLE z = EXPM1 (MINUS_ZERO); + ASSERT (z == L_(0.0)); + ASSERT (!!signbit (z) == !!signbit (MINUS_ZERO)); + } + + /* Infinity. */ + ASSERT (EXPM1 (- INFINITY) == - L_(1.0)); + ASSERT (EXPM1 (INFINITY) == INFINITY); +} -- 2.11.0