Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Move the round(3) checks from 't_libm' to their own 't_round'
details: https://anonhg.NetBSD.org/src/rev/b2c99b7af059
branches: trunk
changeset: 763936:b2c99b7af059
user: jruoho <jruoho%NetBSD.org@localhost>
date: Fri Apr 08 06:49:20 2011 +0000
description:
Move the round(3) checks from 't_libm' to their own 't_round'
for consistency. Add -Wfloat-equal and fix comparisons.
diffstat:
distrib/sets/lists/tests/mi | 8 ++++--
tests/lib/libm/Makefile | 5 ++-
tests/lib/libm/t_libm.c | 44 -------------------------------------------
tests/lib/libm/t_round.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 54 insertions(+), 49 deletions(-)
diffs (145 lines):
diff -r 55abee453a2a -r b2c99b7af059 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Fri Apr 08 06:37:50 2011 +0000
+++ b/distrib/sets/lists/tests/mi Fri Apr 08 06:49:20 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.299 2011/04/07 17:38:02 jruoho Exp $
+# $NetBSD: mi,v 1.300 2011/04/08 06:49:20 jruoho Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -459,7 +459,8 @@
./usr/libdata/debug/usr/tests/lib/libm tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libm/t_ceil.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_floor.debug tests-lib-debug debug,atf
-./usr/libdata/debug/usr/tests/lib/libm/t_libm.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libm/t_libm.debug tests-obsolete obsolete
+./usr/libdata/debug/usr/tests/lib/libm/t_round.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_tanh.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libobjc tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libobjc/t_threads.debug tests-lib-debug debug,atf
@@ -1942,7 +1943,8 @@
./usr/tests/lib/libm/Atffile tests-lib-tests atf
./usr/tests/lib/libm/t_ceil tests-lib-tests atf
./usr/tests/lib/libm/t_floor tests-lib-tests atf
-./usr/tests/lib/libm/t_libm tests-lib-tests atf
+./usr/tests/lib/libm/t_libm tests-obsolete obsolete
+./usr/tests/lib/libm/t_round tests-lib-tests atf
./usr/tests/lib/libm/t_tanh tests-lib-tests atf
./usr/tests/lib/libobjc tests-lib-tests atf
./usr/tests/lib/libobjc/Atffile tests-lib-tests atf
diff -r 55abee453a2a -r b2c99b7af059 tests/lib/libm/Makefile
--- a/tests/lib/libm/Makefile Fri Apr 08 06:37:50 2011 +0000
+++ b/tests/lib/libm/Makefile Fri Apr 08 06:49:20 2011 +0000
@@ -1,11 +1,12 @@
-# $NetBSD: Makefile,v 1.3 2011/04/06 09:35:49 jruoho Exp $
+# $NetBSD: Makefile,v 1.4 2011/04/08 06:49:21 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/lib/libm
-TESTS_C+= t_ceil t_floor t_libm t_tanh
+TESTS_C+= t_ceil t_floor t_round t_tanh
LDADD+=-lm
+COPTS+= -Wfloat-equal
.include <bsd.test.mk>
diff -r 55abee453a2a -r b2c99b7af059 tests/lib/libm/t_libm.c
--- a/tests/lib/libm/t_libm.c Fri Apr 08 06:37:50 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/* $NetBSD: t_libm.c,v 1.1 2010/12/20 23:47:23 pgoyette Exp $ */
-
-#include <atf-c.h>
-#include <math.h>
-
-/*
- * This tests for a bug in the initial implementation where precision
- * was lost in an internal substraction, leading to rounding
- * into the wrong direction.
- */
-
-ATF_TC(round);
-
-/* 0.5 - EPSILON */
-#define VAL 0x0.7ffffffffffffcp0
-#define VALF 0x0.7fffff8p0
-
-ATF_TC_HEAD(round, tc)
-{
- atf_tc_set_md_var(tc, "descr", "Check for rounding in wrong direction");
-}
-
-ATF_TC_BODY(round, tc)
-{
- double a = VAL, b, c;
- float af = VALF, bf, cf;
-
- b = round(a);
- bf = roundf(af);
- c = round(-a);
- cf = roundf(-af);
- ATF_REQUIRE(b == 0);
- ATF_REQUIRE(bf == 0);
- ATF_REQUIRE(c == 0);
- ATF_REQUIRE(cf == 0);
-}
-
-ATF_TP_ADD_TCS(tp)
-{
-
- ATF_TP_ADD_TC(tp, round);
-
- return atf_no_error();
-}
diff -r 55abee453a2a -r b2c99b7af059 tests/lib/libm/t_round.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libm/t_round.c Fri Apr 08 06:49:20 2011 +0000
@@ -0,0 +1,46 @@
+/* $NetBSD: t_round.c,v 1.1 2011/04/08 06:49:21 jruoho Exp $ */
+
+#include <atf-c.h>
+#include <math.h>
+
+/*
+ * This tests for a bug in the initial implementation where
+ * precision was lost in an internal substraction, leading to
+ * rounding into the wrong direction.
+ */
+
+/* 0.5 - EPSILON */
+#define VAL 0x0.7ffffffffffffcp0
+#define VALF 0x0.7fffff8p0
+
+ATF_TC(round_dir);
+ATF_TC_HEAD(round_dir, tc)
+{
+ atf_tc_set_md_var(tc, "descr","Check for rounding in wrong direction");
+}
+
+ATF_TC_BODY(round_dir, tc)
+{
+ double a = VAL, b, c;
+ float af = VALF, bf, cf;
+
+ b = round(a);
+ bf = roundf(af);
+
+ ATF_REQUIRE(fabs(b) < 1.0e-40);
+ ATF_REQUIRE(fabsf(bf) < 1.0e-40);
+
+ c = round(-a);
+ cf = roundf(-af);
+
+ ATF_REQUIRE(fabs(c) < 1.0e-40);
+ ATF_REQUIRE(fabsf(cf) < 1.0e-40);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, round_dir);
+
+ return atf_no_error();
+}
Home |
Main Index |
Thread Index |
Old Index