changeset 16589:338bc8a6f860

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.
author Bruno Haible <bruno@clisp.org>
date Wed, 07 Mar 2012 00:39:56 +0100
parents 6312b64c2c23
children 5e3f83eb0d0c
files ChangeLog modules/expm1-ieee-tests tests/test-expm1-ieee.c tests/test-expm1-ieee.h
diffstat 4 files changed, 112 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2012-03-06  Bruno Haible  <bruno@clisp.org>
 
+	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.
new file mode 100644
--- /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@
new file mode 100644
--- /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 <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <math.h>
+
+#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;
+}
new file mode 100644
--- /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 <http://www.gnu.org/licenses/>.  */
+
+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);
+}