Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libc Move unsigned int/long conversion test to the...



details:   https://anonhg.NetBSD.org/src/rev/61c3b4f75837
branches:  trunk
changeset: 766054:61c3b4f75837
user:      njoly <njoly%NetBSD.org@localhost>
date:      Tue Jun 14 11:58:22 2011 +0000

description:
Move unsigned int/long conversion test to their own testcases, to
avoid having the whole marked as skipped. While here update testcases
names.

diffstat:

 tests/lib/libc/t_convfp.c |  56 ++++++++++++++++++++++++++++------------------
 1 files changed, 34 insertions(+), 22 deletions(-)

diffs (135 lines):

diff -r 2cf49d0ef401 -r 61c3b4f75837 tests/lib/libc/t_convfp.c
--- a/tests/lib/libc/t_convfp.c Tue Jun 14 11:45:26 2011 +0000
+++ b/tests/lib/libc/t_convfp.c Tue Jun 14 11:58:22 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_convfp.c,v 1.6 2011/06/11 18:03:18 christos Exp $    */
+/*     $NetBSD: t_convfp.c,v 1.7 2011/06/14 11:58:22 njoly Exp $       */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -43,19 +43,16 @@
 #define ULONG_TESTVALUE        (LONG_MAX+42UL)
 
 
-ATF_TC(test1);
-
-ATF_TC_HEAD(test1, tc)
+ATF_TC(conv_uint);
+ATF_TC_HEAD(conv_uint, tc)
 {
 
-       atf_tc_set_md_var(tc, "descr", "test conversions to unsigned int/long");
+       atf_tc_set_md_var(tc, "descr", "test conversions to unsigned int");
 }
 
-ATF_TC_BODY(test1, tc)
+ATF_TC_BODY(conv_uint, tc)
 {
        unsigned int ui;
-       unsigned long ul;
-       long double dt;
        double d;
 
        /* unsigned int test */
@@ -65,6 +62,21 @@
        if (ui != UINT_TESTVALUE)
                atf_tc_fail("FAILED: unsigned int %u (0x%x) != %u (0x%x)",
                    ui, ui, UINT_TESTVALUE, UINT_TESTVALUE);
+}
+
+ATF_TC(conv_ulong);
+
+ATF_TC_HEAD(conv_ulong, tc)
+{
+
+       atf_tc_set_md_var(tc, "descr", "test conversions to unsigned long");
+}
+
+ATF_TC_BODY(conv_ulong, tc)
+{
+       unsigned long ul;
+       long double dt;
+       double d;
 
        /* unsigned long vs. {long} double test */
        if (sizeof(d) > sizeof(ul)) {
@@ -79,8 +91,7 @@
                printf("sizeof(long) = %zu, sizeof(double) = %zu, "
                    "sizeof(long double) = %zu\n", 
                    sizeof(ul), sizeof(d), sizeof(dt));
-               atf_tc_skip("no suitable {long} double type found, skipping "
-                   "\"unsigned long\" test");
+               atf_tc_skip("no suitable {long} double type found");
        }
 
        if (ul != ULONG_TESTVALUE)
@@ -88,15 +99,15 @@
                    ul, ul, ULONG_TESTVALUE, ULONG_TESTVALUE);
 }
 
-ATF_TC(test2);
+ATF_TC(cast_ulong);
 
-ATF_TC_HEAD(test2, tc)
+ATF_TC_HEAD(cast_ulong, tc)
 {
 
        atf_tc_set_md_var(tc, "descr", "test double to unsigned long cast");
 }
 
-ATF_TC_BODY(test2, tc)
+ATF_TC_BODY(cast_ulong, tc)
 {
        double nv;
        unsigned long uv;
@@ -104,30 +115,30 @@
        nv = 5.6;
        uv = (unsigned long)nv;
 
-       ATF_REQUIRE_EQ_MSG(uv, 5,
+       ATF_CHECK_EQ_MSG(uv, 5,
            "%.3f casted to unsigned long is %lu", nv, uv);
 }
 
-ATF_TC(test3);
+ATF_TC(cast_ulong2);
 
-ATF_TC_HEAD(test3, tc)
+ATF_TC_HEAD(cast_ulong2, tc)
 {
 
        atf_tc_set_md_var(tc, "descr",
            "test double/long double casts to unsigned long");
 }
 
-ATF_TC_BODY(test3, tc)
+ATF_TC_BODY(cast_ulong2, tc)
 {
        double dv = 1.9;
        long double ldv = dv;
        unsigned long l1 = dv;
        unsigned long l2 = ldv;
 
-       ATF_REQUIRE_EQ_MSG(l1, 1,
+       ATF_CHECK_EQ_MSG(l1, 1,
            "double 1.9 casted to unsigned long should be 1, but is %lu", l1);
 
-       ATF_REQUIRE_EQ_MSG(l2, 1,
+       ATF_CHECK_EQ_MSG(l2, 1,
            "long double 1.9 casted to unsigned long should be 1, but is %lu",
            l2);
 }
@@ -135,9 +146,10 @@
 ATF_TP_ADD_TCS(tp)
 {
 
-       ATF_TP_ADD_TC(tp, test1);
-       ATF_TP_ADD_TC(tp, test2);
-       ATF_TP_ADD_TC(tp, test3);
+       ATF_TP_ADD_TC(tp, conv_uint);
+       ATF_TP_ADD_TC(tp, conv_ulong);
+       ATF_TP_ADD_TC(tp, cast_ulong);
+       ATF_TP_ADD_TC(tp, cast_ulong2);
 
        return atf_no_error();
 }



Home | Main Index | Thread Index | Old Index