summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2012-04-07 04:00:30 +0000
committerdas <das@FreeBSD.org>2012-04-07 04:00:30 +0000
commit311b105c66a060e0ff2789f0047b59fb66bef2b1 (patch)
tree34b03cbdf7aac576217e971254d017ddae59ec79
parent5d2625f37f906b2187ea184cba9c2cc28f46d988 (diff)
downloadFreeBSD-src-311b105c66a060e0ff2789f0047b59fb66bef2b1.zip
FreeBSD-src-311b105c66a060e0ff2789f0047b59fb66bef2b1.tar.gz
Add some tests from PR 166463. Also make sure that all of the tests,
old and new, check the sign bits of both the remainder and the quotient.
-rw-r--r--tools/regression/lib/msun/test-rem.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/tools/regression/lib/msun/test-rem.c b/tools/regression/lib/msun/test-rem.c
index a184e9d..840bea3 100644
--- a/tools/regression/lib/msun/test-rem.c
+++ b/tools/regression/lib/msun/test-rem.c
@@ -55,7 +55,7 @@ int
main(int argc, char *argv[])
{
- printf("1..2\n");
+ printf("1..3\n");
test_invalid(0.0, 0.0);
test_invalid(1.0, 0.0);
@@ -96,6 +96,14 @@ main(int argc, char *argv[])
printf("ok 2 - rem\n");
+ test(0x1.66666cp+120, 0x1p+71, 0.0, 1476395008);
+ testd(-0x1.0000000000003p+0, 0x1.0000000000003p+0, -0.0, -1);
+ testl(-0x1.0000000000003p+0, 0x1.0000000000003p+0, -0.0, -1);
+ testd(-0x1.0000000000001p-749, 0x1.4p-1072, 0x1p-1074, -1288490189);
+ testl(-0x1.0000000000001p-749, 0x1.4p-1072, 0x1p-1074, -1288490189);
+
+ printf("ok 3 - rem\n");
+
return (0);
}
@@ -136,10 +144,16 @@ static void
testl(long double x, long double y, long double expected_rem, int expected_quo)
{
int q;
+ long double rem;
q = random();
- assert(remainderl(x, y) == expected_rem);
- assert(remquol(x, y, &q) == expected_rem);
+ rem = remainderl(x, y);
+ assert(rem == expected_rem);
+ assert(!signbit(rem) == !signbit(expected_rem));
+ rem = remquol(x, y, &q);
+ assert(rem == expected_rem);
+ assert(!signbit(rem) == !signbit(expected_rem));
+ assert((q ^ expected_quo) >= 0); /* sign(q) == sign(expected_quo) */
assert((q & 0x7) == (expected_quo & 0x7));
if (q != 0) {
assert((q > 0) ^ !(expected_quo > 0));
@@ -152,10 +166,16 @@ static void
testd(double x, double y, double expected_rem, int expected_quo)
{
int q;
+ double rem;
q = random();
- assert(remainder(x, y) == expected_rem);
- assert(remquo(x, y, &q) == expected_rem);
+ rem = remainder(x, y);
+ assert(rem == expected_rem);
+ assert(!signbit(rem) == !signbit(expected_rem));
+ rem = remquo(x, y, &q);
+ assert(rem == expected_rem);
+ assert(!signbit(rem) == !signbit(expected_rem));
+ assert((q ^ expected_quo) >= 0); /* sign(q) == sign(expected_quo) */
assert((q & 0x7) == (expected_quo & 0x7));
if (q != 0) {
assert((q > 0) ^ !(expected_quo > 0));
@@ -168,10 +188,16 @@ static void
testf(float x, float y, float expected_rem, int expected_quo)
{
int q;
+ float rem;
q = random();
- assert(remainderf(x, y) == expected_rem);
- assert(remquof(x, y, &q) == expected_rem);
+ rem = remainderf(x, y);
+ assert(rem == expected_rem);
+ assert(!signbit(rem) == !signbit(expected_rem));
+ rem = remquof(x, y, &q);
+ assert(rem == expected_rem);
+ assert(!signbit(rem) == !signbit(expected_rem));
+ assert((q ^ expected_quo) >= 0); /* sign(q) == sign(expected_quo) */
assert((q & 0x7) == (expected_quo & 0x7));
if (q != 0) {
assert((q > 0) ^ !(expected_quo > 0));
OpenPOWER on IntegriCloud