Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libm Add more assertions.



details:   https://anonhg.NetBSD.org/src/rev/b331020eec06
branches:  trunk
changeset: 769500:b331020eec06
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Mon Sep 12 15:47:14 2011 +0000

description:
Add more assertions.

diffstat:

 tests/lib/libm/t_ldexp.c  |  48 +++++++++++++++++++++++++------
 tests/lib/libm/t_scalbn.c |  70 +++++++++++++++++++++++++++++++++++++---------
 2 files changed, 94 insertions(+), 24 deletions(-)

diffs (271 lines):

diff -r edcad0afb393 -r b331020eec06 tests/lib/libm/t_ldexp.c
--- a/tests/lib/libm/t_ldexp.c  Mon Sep 12 15:27:40 2011 +0000
+++ b/tests/lib/libm/t_ldexp.c  Mon Sep 12 15:47:14 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ldexp.c,v 1.1 2011/09/12 15:27:40 jruoho Exp $ */
+/* $NetBSD: t_ldexp.c,v 1.2 2011/09/12 15:47:14 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ldexp.c,v 1.1 2011/09/12 15:27:40 jruoho Exp $");
+__RCSID("$NetBSD: t_ldexp.c,v 1.2 2011/09/12 15:47:14 jruoho Exp $");
 
 #include <math.h>
 #include <limits.h>
@@ -53,6 +53,8 @@
        double y;
        size_t i;
 
+       ATF_REQUIRE(isnan(x) != 0);
+
        for (i = 0; i < __arraycount(exps); i++) {
                y = ldexp(x, exps[i]);
                ATF_CHECK(isnan(y) != 0);
@@ -98,10 +100,16 @@
 ATF_TC_BODY(ldexp_zero_neg, tc)
 {
        const double x = -0.0L;
+       double y;
        size_t i;
 
-       for (i = 0; i < __arraycount(exps); i++)
-               ATF_CHECK(ldexp(x, exps[i]) == x);
+       ATF_REQUIRE(signbit(x) != 0);
+
+       for (i = 0; i < __arraycount(exps); i++) {
+               y = ldexp(x, exps[i]);
+               ATF_CHECK(x == y);
+               ATF_CHECK(signbit(y) != 0);
+       }
 }
 
 ATF_TC(ldexp_zero_pos);
@@ -113,10 +121,16 @@
 ATF_TC_BODY(ldexp_zero_pos, tc)
 {
        const double x = 0.0L;
+       double y;
        size_t i;
 
-       for (i = 0; i < __arraycount(exps); i++)
-               ATF_CHECK(ldexp(x, exps[i]) == x);
+       ATF_REQUIRE(signbit(x) == 0);
+
+       for (i = 0; i < __arraycount(exps); i++) {
+               y = ldexp(x, exps[i]);
+               ATF_CHECK(x == y);
+               ATF_CHECK(signbit(y) == 0);
+       }
 }
 
 ATF_TC(ldexpf_nan);
@@ -131,6 +145,8 @@
        float y;
        size_t i;
 
+       ATF_REQUIRE(isnan(x) != 0);
+
        for (i = 0; i < __arraycount(exps); i++) {
                y = ldexpf(x, exps[i]);
                ATF_CHECK(isnan(y) != 0);
@@ -180,10 +196,16 @@
 ATF_TC_BODY(ldexpf_zero_neg, tc)
 {
        const float x = -0.0L;
+       float y;
        size_t i;
 
-       for (i = 0; i < __arraycount(exps); i++)
-               ATF_CHECK(ldexpf(x, exps[i]) == x);
+       ATF_REQUIRE(signbit(x) != 0);
+
+       for (i = 0; i < __arraycount(exps); i++) {
+               y = ldexpf(x, exps[i]);
+               ATF_CHECK(x == y);
+               ATF_CHECK(signbit(y) != 0);
+       }
 }
 
 ATF_TC(ldexpf_zero_pos);
@@ -195,10 +217,16 @@
 ATF_TC_BODY(ldexpf_zero_pos, tc)
 {
        const float x = 0.0L;
+       float y;
        size_t i;
 
-       for (i = 0; i < __arraycount(exps); i++)
-               ATF_CHECK(ldexpf(x, exps[i]) == x);
+       ATF_REQUIRE(signbit(x) == 0);
+
+       for (i = 0; i < __arraycount(exps); i++) {
+               y = ldexpf(x, exps[i]);
+               ATF_CHECK(x == y);
+               ATF_CHECK(signbit(y) == 0);
+       }
 }
 
 ATF_TP_ADD_TCS(tp)
diff -r edcad0afb393 -r b331020eec06 tests/lib/libm/t_scalbn.c
--- a/tests/lib/libm/t_scalbn.c Mon Sep 12 15:27:40 2011 +0000
+++ b/tests/lib/libm/t_scalbn.c Mon Sep 12 15:47:14 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_scalbn.c,v 1.1 2011/09/12 15:27:40 jruoho Exp $ */
+/* $NetBSD: t_scalbn.c,v 1.2 2011/09/12 15:47:14 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_scalbn.c,v 1.1 2011/09/12 15:27:40 jruoho Exp $");
+__RCSID("$NetBSD: t_scalbn.c,v 1.2 2011/09/12 15:47:14 jruoho Exp $");
 
 #include <math.h>
 #include <limits.h>
@@ -53,6 +53,8 @@
        double y;
        size_t i;
 
+       ATF_REQUIRE(isnan(x) != 0);
+
        for (i = 0; i < __arraycount(exps); i++) {
                y = scalbn(x, exps[i]);
                ATF_CHECK(isnan(y) != 0);
@@ -98,10 +100,16 @@
 ATF_TC_BODY(scalbn_zero_neg, tc)
 {
        const double x = -0.0L;
+       double y;
        size_t i;
 
-       for (i = 0; i < __arraycount(exps); i++)
-               ATF_CHECK(scalbn(x, exps[i]) == x);
+       ATF_REQUIRE(signbit(x) != 0);
+
+       for (i = 0; i < __arraycount(exps); i++) {
+               y = scalbn(x, exps[i]);
+               ATF_CHECK(x == y);
+               ATF_CHECK(signbit(y) != 0);
+       }
 }
 
 ATF_TC(scalbn_zero_pos);
@@ -113,10 +121,16 @@
 ATF_TC_BODY(scalbn_zero_pos, tc)
 {
        const double x = 0.0L;
+       double y;
        size_t i;
 
-       for (i = 0; i < __arraycount(exps); i++)
-               ATF_CHECK(scalbn(x, exps[i]) == x);
+       ATF_REQUIRE(signbit(x) == 0);
+
+       for (i = 0; i < __arraycount(exps); i++) {
+               y = scalbn(x, exps[i]);
+               ATF_CHECK(x == y);
+               ATF_CHECK(signbit(y) == 0);
+       }
 }
 
 /*
@@ -134,6 +148,8 @@
        float y;
        size_t i;
 
+       ATF_REQUIRE(isnan(x) != 0);
+
        for (i = 0; i < __arraycount(exps); i++) {
                y = scalbnf(x, exps[i]);
                ATF_CHECK(isnan(y) != 0);
@@ -179,10 +195,16 @@
 ATF_TC_BODY(scalbnf_zero_neg, tc)
 {
        const float x = -0.0L;
+       float y;
        size_t i;
 
-       for (i = 0; i < __arraycount(exps); i++)
-               ATF_CHECK(scalbnf(x, exps[i]) == x);
+       ATF_REQUIRE(signbit(x) != 0);
+
+       for (i = 0; i < __arraycount(exps); i++) {
+               y = scalbnf(x, exps[i]);
+               ATF_CHECK(x == y);
+               ATF_CHECK(signbit(y) != 0);
+       }
 }
 
 ATF_TC(scalbnf_zero_pos);
@@ -194,10 +216,16 @@
 ATF_TC_BODY(scalbnf_zero_pos, tc)
 {
        const float x = 0.0L;
+       float y;
        size_t i;
 
-       for (i = 0; i < __arraycount(exps); i++)
-               ATF_CHECK(scalbnf(x, exps[i]) == x);
+       ATF_REQUIRE(signbit(x) == 0);
+
+       for (i = 0; i < __arraycount(exps); i++) {
+               y = scalbnf(x, exps[i]);
+               ATF_CHECK(x == y);
+               ATF_CHECK(signbit(y) == 0);
+       }
 }
 
 /*
@@ -218,6 +246,8 @@
        long double y;
        size_t i;
 
+       ATF_REQUIRE(isnan(x) != 0);
+
        for (i = 0; i < __arraycount(exps); i++) {
                y = scalbnl(x, exps[i]);
                ATF_CHECK(isnan(y) != 0);
@@ -275,10 +305,16 @@
        atf_tc_skip("Requires long double support");
 #else
        const long double x = -0.0L;
+       long double y;
        size_t i;
 
-       for (i = 0; i < __arraycount(exps); i++)
-               ATF_CHECK(scalbnl(x, exps[i]) == x);
+       ATF_REQUIRE(signbit(x) != 0);
+
+       for (i = 0; i < __arraycount(exps); i++) {
+               y = scalbnl(x, exps[i]);
+               ATF_CHECK(x == y);
+               ATF_CHECK(signbit(y) != 0);
+       }
 #endif
 }
 
@@ -294,10 +330,16 @@
        atf_tc_skip("Requires long double support");
 #else
        const long double x = 0.0L;
+       long double y;
        size_t i;
 
-       for (i = 0; i < __arraycount(exps); i++)
-               ATF_CHECK(scalbnl(x, exps[i]) == x);
+       ATF_REQUIRE(signbit(x) == 0);
+
+       for (i = 0; i < __arraycount(exps); i++) {
+               y = scalbnl(x, exps[i]);
+               ATF_CHECK(x == y);
+               ATF_CHECK(signbit(y) == 0);
+       }
 #endif
 }
 



Home | Main Index | Thread Index | Old Index