summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-03-03 17:17:19 +0100
committerBruno Haible <bruno@clisp.org>2012-03-03 17:49:33 +0100
commite342ff35944348fd2c2c8d154c639defb6268694 (patch)
treeed64f587fa1252ef15f30051b048beeb7fb96601
parent80c3530fa6f0b67feb8e3a01c6ae0f3074d8129d (diff)
downloadgnulib-e342ff35944348fd2c2c8d154c639defb6268694.tar.gz
rint* tests: More tests.
* tests/test-rint.h: New file, partially extracted from tests/test-rintl.c. * tests/test-rint.c: Include test-rint.h. (main): Invoke test_function. * tests/test-rintf.c: Include test-rint.h. (main): Invoke test_function. * tests/test-rintl.c: Include test-rint.h. (main): Invoke test_function. * modules/rint-tests (Files): Add tests/test-rint.h, tests/randomd.c. (Makefile.am): Add randomd.c to test_rint_SOURCES. * modules/rintf-tests (Files): Add tests/test-rint.h, tests/randomf.c. (Makefile.am): Add randomf.c to test_rintf_SOURCES. * modules/rintl-tests (Files): Add tests/test-rint.h, tests/randoml.c. (Makefile.am): Add randoml.c to test_rintl_SOURCES.
-rw-r--r--ChangeLog18
-rw-r--r--modules/rint-tests3
-rw-r--r--modules/rintf-tests3
-rw-r--r--modules/rintl-tests3
-rw-r--r--tests/test-rint.c16
-rw-r--r--tests/test-rint.h55
-rw-r--r--tests/test-rintf.c16
-rw-r--r--tests/test-rintl.c16
8 files changed, 115 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 20483c7d23..bf20a7aa0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2012-03-03 Bruno Haible <bruno@clisp.org>
+ rint* tests: More tests.
+ * tests/test-rint.h: New file, partially extracted from
+ tests/test-rintl.c.
+ * tests/test-rint.c: Include test-rint.h.
+ (main): Invoke test_function.
+ * tests/test-rintf.c: Include test-rint.h.
+ (main): Invoke test_function.
+ * tests/test-rintl.c: Include test-rint.h.
+ (main): Invoke test_function.
+ * modules/rint-tests (Files): Add tests/test-rint.h, tests/randomd.c.
+ (Makefile.am): Add randomd.c to test_rint_SOURCES.
+ * modules/rintf-tests (Files): Add tests/test-rint.h, tests/randomf.c.
+ (Makefile.am): Add randomf.c to test_rintf_SOURCES.
+ * modules/rintl-tests (Files): Add tests/test-rint.h, tests/randoml.c.
+ (Makefile.am): Add randoml.c to test_rintl_SOURCES.
+
+2012-03-03 Bruno Haible <bruno@clisp.org>
+
modf* tests: More tests.
* tests/test-modf.h: New file.
* tests/test-modf.c: Include <float.h> and test-modf.h.
diff --git a/modules/rint-tests b/modules/rint-tests
index bb69767a03..1b0232f760 100644
--- a/modules/rint-tests
+++ b/modules/rint-tests
@@ -1,10 +1,12 @@
Files:
tests/test-rint.c
+tests/test-rint.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
+tests/randomd.c
Depends-on:
isnand-nolibm
@@ -14,4 +16,5 @@ configure.ac:
Makefile.am:
TESTS += test-rint
check_PROGRAMS += test-rint
+test_rint_SOURCES = test-rint.c randomd.c
test_rint_LDADD = $(LDADD) @RINT_LIBM@
diff --git a/modules/rintf-tests b/modules/rintf-tests
index 1b5a9c1a4e..d72ce79167 100644
--- a/modules/rintf-tests
+++ b/modules/rintf-tests
@@ -1,10 +1,12 @@
Files:
tests/test-rintf.c
+tests/test-rint.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
+tests/randomf.c
Depends-on:
isnanf-nolibm
@@ -14,4 +16,5 @@ configure.ac:
Makefile.am:
TESTS += test-rintf
check_PROGRAMS += test-rintf
+test_rintf_SOURCES = test-rintf.c randomf.c
test_rintf_LDADD = $(LDADD) @RINTF_LIBM@
diff --git a/modules/rintl-tests b/modules/rintl-tests
index 3a1d80dd9a..32dd4b4257 100644
--- a/modules/rintl-tests
+++ b/modules/rintl-tests
@@ -1,10 +1,12 @@
Files:
tests/test-rintl.c
+tests/test-rint.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
+tests/randoml.c
Depends-on:
fpucw
@@ -16,4 +18,5 @@ configure.ac:
Makefile.am:
TESTS += test-rintl
check_PROGRAMS += test-rintl
+test_rintl_SOURCES = test-rintl.c randoml.c
test_rintl_LDADD = $(LDADD) @RINTL_LIBM@
diff --git a/tests/test-rint.c b/tests/test-rint.c
index 075d05d9a2..869a0a123f 100644
--- a/tests/test-rint.c
+++ b/tests/test-rint.c
@@ -32,6 +32,15 @@ SIGNATURE_CHECK (rint, double, (double));
#include "nan.h"
#include "macros.h"
+#define DOUBLE double
+#define ISNAN isnand
+#define INFINITY Infinityd ()
+#define NAN NaNd ()
+#define L_(literal) literal
+#define RINT rint
+#define RANDOM randomd
+#include "test-rint.h"
+
int
main ()
{
@@ -75,11 +84,8 @@ main ()
ASSERT (rint (-65536.0) == -65536.0);
ASSERT (rint (-65536.001) == -65536.0);
ASSERT (rint (-2.341e31) == -2.341e31);
- /* Infinite numbers. */
- ASSERT (rint (Infinityd ()) == Infinityd ());
- ASSERT (rint (- Infinityd ()) == - Infinityd ());
- /* NaNs. */
- ASSERT (isnand (rint (NaNd ())));
+
+ test_function ();
return 0;
}
diff --git a/tests/test-rint.h b/tests/test-rint.h
new file mode 100644
index 0000000000..5ae814635b
--- /dev/null
+++ b/tests/test-rint.h
@@ -0,0 +1,55 @@
+/* Test of rint*() 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)
+{
+ /* Infinite numbers. */
+ ASSERT (RINT (INFINITY) == INFINITY);
+ ASSERT (RINT (- INFINITY) == - INFINITY);
+ /* NaNs. */
+ ASSERT (ISNAN (RINT (NAN)));
+
+ /* Randomized tests. */
+ {
+ int i;
+
+ for (i = 0; i < SIZEOF (RANDOM); i++)
+ {
+ DOUBLE x;
+
+ x = L_(0.5) * RANDOM[i];
+ ASSERT (RINT (x) == L_(0.0));
+ x = - x;
+ ASSERT (RINT (x) == L_(0.0));
+
+ x = L_(1.0) - L_(0.5) * RANDOM[i];
+ ASSERT (RINT (x) == L_(1.0));
+ x = - x;
+ ASSERT (RINT (x) == - L_(1.0));
+
+ x = L_(1.0) + L_(0.5) * RANDOM[i];
+ ASSERT (RINT (x) == L_(1.0));
+ x = - x;
+ ASSERT (RINT (x) == - L_(1.0));
+
+ x = L_(2.0) - L_(0.5) * RANDOM[i];
+ ASSERT (RINT (x) == L_(2.0));
+ x = - x;
+ ASSERT (RINT (x) == - L_(2.0));
+ }
+ }
+}
diff --git a/tests/test-rintf.c b/tests/test-rintf.c
index da4af98ba9..cd8951af9d 100644
--- a/tests/test-rintf.c
+++ b/tests/test-rintf.c
@@ -32,6 +32,15 @@ SIGNATURE_CHECK (rintf, float, (float));
#include "nan.h"
#include "macros.h"
+#define DOUBLE float
+#define ISNAN isnanf
+#define INFINITY Infinityf ()
+#define NAN NaNf ()
+#define L_(literal) literal##f
+#define RINT rintf
+#define RANDOM randomf
+#include "test-rint.h"
+
int
main ()
{
@@ -75,11 +84,8 @@ main ()
ASSERT (rintf (-65536.0f) == -65536.0f);
ASSERT (rintf (-65536.01f) == -65536.0f);
ASSERT (rintf (-2.341e31f) == -2.341e31f);
- /* Infinite numbers. */
- ASSERT (rintf (Infinityf ()) == Infinityf ());
- ASSERT (rintf (- Infinityf ()) == - Infinityf ());
- /* NaNs. */
- ASSERT (isnanf (rintf (NaNf ())));
+
+ test_function ();
return 0;
}
diff --git a/tests/test-rintl.c b/tests/test-rintl.c
index a960eaa419..d7f861675b 100644
--- a/tests/test-rintl.c
+++ b/tests/test-rintl.c
@@ -33,6 +33,15 @@ SIGNATURE_CHECK (rintl, long double, (long double));
#include "nan.h"
#include "macros.h"
+#define DOUBLE long double
+#define ISNAN isnanl
+#define INFINITY Infinityl ()
+#define NAN NaNl ()
+#define L_(literal) literal##L
+#define RINT rintl
+#define RANDOM randoml
+#include "test-rint.h"
+
int
main ()
{
@@ -80,11 +89,8 @@ main ()
ASSERT (rintl (-65536.0L) == -65536.0L);
ASSERT (rintl (-65536.001L) == -65536.0L);
ASSERT (rintl (-2.341e31L) == -2.341e31L);
- /* Infinite numbers. */
- ASSERT (rintl (Infinityl ()) == Infinityl ());
- ASSERT (rintl (- Infinityl ()) == - Infinityl ());
- /* NaNs. */
- ASSERT (isnanl (rintl (NaNl ())));
+
+ test_function ();
return 0;
}