summaryrefslogtreecommitdiffstats
path: root/tools/regression/lib
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2008-03-30 20:48:33 +0000
committerdas <das@FreeBSD.org>2008-03-30 20:48:33 +0000
commit9a915147fb07a6c1bafe359bf631c5bb09d1d757 (patch)
tree9a9a73208edbc2329a5c65d58a0c1cd4df6e5e12 /tools/regression/lib
parentf487ba5286768e2381c4eda3bcad62bbc29a5621 (diff)
downloadFreeBSD-src-9a915147fb07a6c1bafe359bf631c5bb09d1d757.zip
FreeBSD-src-9a915147fb07a6c1bafe359bf631c5bb09d1d757.tar.gz
Test remainderl() and remquol() as well.
Diffstat (limited to 'tools/regression/lib')
-rw-r--r--tools/regression/lib/msun/test-rem.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/tools/regression/lib/msun/test-rem.c b/tools/regression/lib/msun/test-rem.c
index a4b09c9..a184e9d 100644
--- a/tools/regression/lib/msun/test-rem.c
+++ b/tools/regression/lib/msun/test-rem.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.org>
+ * Copyright (c) 2005-2008 David Schultz <das@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,8 @@
*/
/*
- * Test for remainder functions: remainder, remainderf, remquo, remquof.
+ * Test for remainder functions: remainder, remainderf, remainderl,
+ * remquo, remquof, and remquol.
* Missing tests: fmod, fmodf.
*/
@@ -33,16 +34,19 @@
__FBSDID("$FreeBSD$");
#include <assert.h>
+#include <float.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
-static void test_invalid(double, double);
+static void test_invalid(long double, long double);
+static void testl(long double, long double, long double, int);
static void testd(double, double, double, int);
static void testf(float, float, float, int);
#define test(x, y, e_r, e_q) do { \
+ testl(x, y, e_r, e_q); \
testd(x, y, e_r, e_q); \
testf(x, y, e_r, e_q); \
} while (0)
@@ -70,6 +74,10 @@ main(int argc, char *argv[])
testd(275 * 1193040, 275, 0, 1193040);
test(4.5 * 7.5, 4.5, -2.25, 8); /* we should get the even one */
testf(0x1.9044f6p-1, 0x1.ce662ep-1, -0x1.f109cp-4, 1);
+#if LDBL_MANT_DIG > 53
+ testl(-0x1.23456789abcdefp-2000L, 0x1.fedcba987654321p-2000L,
+ 0x1.b72ea61d950c862p-2001L, -1);
+#endif
printf("ok 1 - rem\n");
@@ -92,7 +100,7 @@ main(int argc, char *argv[])
}
static void
-test_invalid(double x, double y)
+test_invalid(long double x, long double y)
{
int q;
@@ -109,6 +117,12 @@ test_invalid(double x, double y)
#ifdef STRICT
assert(q == 0xdeadbeef);
#endif
+
+ assert(isnan(remainderl(x, y)));
+ assert(isnan(remquol(x, y, &q)));
+#ifdef STRICT
+ assert(q == 0xdeadbeef);
+#endif
}
/* 0x012345 ==> 0x01ffff */
@@ -119,6 +133,22 @@ mask(int x)
}
static void
+testl(long double x, long double y, long double expected_rem, int expected_quo)
+{
+ int q;
+
+ q = random();
+ assert(remainderl(x, y) == expected_rem);
+ assert(remquol(x, y, &q) == expected_rem);
+ assert((q & 0x7) == (expected_quo & 0x7));
+ if (q != 0) {
+ assert((q > 0) ^ !(expected_quo > 0));
+ q = abs(q);
+ assert(q == (abs(expected_quo) & mask(q)));
+ }
+}
+
+static void
testd(double x, double y, double expected_rem, int expected_quo)
{
int q;
OpenPOWER on IntegriCloud