Tests for module 'expm1-ieee'.
authorBruno Haible <bruno@clisp.org>
Tue, 6 Mar 2012 23:39:56 +0000 (00:39 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 6 Mar 2012 23:39:56 +0000 (00:39 +0100)
* modules/expm1-ieee-tests: New file.
* tests/test-expm1-ieee.c: New file.
* tests/test-expm1-ieee.h: New file.

ChangeLog
modules/expm1-ieee-tests [new file with mode: 0644]
tests/test-expm1-ieee.c [new file with mode: 0644]
tests/test-expm1-ieee.h [new file with mode: 0644]

index 56dd9fe..37344ac 100644 (file)
--- 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.
diff --git a/modules/expm1-ieee-tests b/modules/expm1-ieee-tests
new file mode 100644 (file)
index 0000000..4569a7b
--- /dev/null
@@ -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 (file)
index 0000000..87dc9d2
--- /dev/null
@@ -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;
+}
diff --git a/tests/test-expm1-ieee.h b/tests/test-expm1-ieee.h
new file mode 100644 (file)
index 0000000..fee764f
--- /dev/null
@@ -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);
+}