Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Few tests for the error functions.
details: https://anonhg.NetBSD.org/src/rev/9c02c7680a51
branches: trunk
changeset: 769662:9c02c7680a51
user: jruoho <jruoho%NetBSD.org@localhost>
date: Sat Sep 17 12:00:50 2011 +0000
description:
Few tests for the error functions.
diffstat:
distrib/sets/lists/tests/mi | 4 +-
tests/lib/libm/Makefile | 3 +-
tests/lib/libm/t_erf.c | 331 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 336 insertions(+), 2 deletions(-)
diffs (truncated from 377 to 300 lines):
diff -r dd6854612b37 -r 9c02c7680a51 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sat Sep 17 10:52:52 2011 +0000
+++ b/distrib/sets/lists/tests/mi Sat Sep 17 12:00:50 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.386 2011/09/17 08:15:43 jruoho Exp $
+# $NetBSD: mi,v 1.387 2011/09/17 12:00:50 jruoho Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -548,6 +548,7 @@
./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_cos.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libm/t_erf.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_floor.debug tests-obsolete obsolete
./usr/libdata/debug/usr/tests/lib/libm/t_infinity.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_ldexp.debug tests-lib-debug debug,atf
@@ -2258,6 +2259,7 @@
./usr/tests/lib/libm/Atffile tests-lib-tests atf
./usr/tests/lib/libm/t_ceil tests-lib-tests atf
./usr/tests/lib/libm/t_cos tests-lib-tests atf
+./usr/tests/lib/libm/t_erf tests-lib-tests atf
./usr/tests/lib/libm/t_floor tests-obsolete obsolete
./usr/tests/lib/libm/t_infinity tests-lib-tests atf
./usr/tests/lib/libm/t_ldexp tests-lib-tests atf
diff -r dd6854612b37 -r 9c02c7680a51 tests/lib/libm/Makefile
--- a/tests/lib/libm/Makefile Sat Sep 17 10:52:52 2011 +0000
+++ b/tests/lib/libm/Makefile Sat Sep 17 12:00:50 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2011/09/17 08:15:43 jruoho Exp $
+# $NetBSD: Makefile,v 1.11 2011/09/17 12:00:50 jruoho Exp $
.include <bsd.own.mk>
@@ -6,6 +6,7 @@
TESTS_C+= t_ceil
TESTS_C+= t_cos
+TESTS_C+= t_erf
TESTS_C+= t_infinity
TESTS_C+= t_ldexp
TESTS_C+= t_log
diff -r dd6854612b37 -r 9c02c7680a51 tests/lib/libm/t_erf.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libm/t_erf.c Sat Sep 17 12:00:50 2011 +0000
@@ -0,0 +1,331 @@
+/* $NetBSD: t_erf.c,v 1.1 2011/09/17 12:00:50 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_erf.c,v 1.1 2011/09/17 12:00:50 jruoho Exp $");
+
+#include <atf-c.h>
+#include <math.h>
+
+/*
+ * erf(3)
+ */
+ATF_TC(erf_nan);
+ATF_TC_HEAD(erf_nan, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erf(NaN) == NaN");
+}
+
+ATF_TC_BODY(erf_nan, tc)
+{
+#ifndef __vax__
+ const double x = 0.0L / 0.0L;
+
+ ATF_CHECK(isnan(erf(x)) != 0);
+#endif
+}
+
+ATF_TC(erf_inf_neg);
+ATF_TC_HEAD(erf_inf_neg, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erf(-Inf) == -1.0");
+}
+
+ATF_TC_BODY(erf_inf_neg, tc)
+{
+#ifndef __vax__
+ const double x = -1.0L / 0.0L;
+
+ if (erf(x) != -1.0)
+ atf_tc_fail_nonfatal("erf(-Inf) != -1.0");
+#endif
+}
+
+ATF_TC(erf_inf_pos);
+ATF_TC_HEAD(erf_inf_pos, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erf(+Inf) == 1.0");
+}
+
+ATF_TC_BODY(erf_inf_pos, tc)
+{
+#ifndef __vax__
+ const double x = 1.0L / 0.0L;
+
+ if (erf(x) != 1.0)
+ atf_tc_fail_nonfatal("erf(+Inf) != 1.0");
+#endif
+}
+
+ATF_TC(erf_zero_neg);
+ATF_TC_HEAD(erf_zero_neg, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erf(-0.0) == -0.0");
+}
+
+ATF_TC_BODY(erf_zero_neg, tc)
+{
+#ifndef __vax__
+ const double x = -0.0L;
+ double y = erf(x);
+
+ if (fabs(y) > 0.0 || signbit(y) == 0)
+ atf_tc_fail_nonfatal("erf(-0.0) != -0.0");
+#endif
+}
+
+ATF_TC(erf_zero_pos);
+ATF_TC_HEAD(erf_zero_pos, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erf(+0.0) == +0.0");
+}
+
+ATF_TC_BODY(erf_zero_pos, tc)
+{
+#ifndef __vax__
+ const double x = 0.0L;
+ double y = erf(x);
+
+ if (fabs(y) > 0.0 || signbit(y) != 0)
+ atf_tc_fail_nonfatal("erf(+0.0) != +0.0");
+#endif
+}
+
+/*
+ * erff(3)
+ */
+ATF_TC(erff_nan);
+ATF_TC_HEAD(erff_nan, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erff(NaN) == NaN");
+}
+
+ATF_TC_BODY(erff_nan, tc)
+{
+#ifndef __vax__
+ const float x = 0.0L / 0.0L;
+
+ ATF_CHECK(isnan(erff(x)) != 0);
+#endif
+}
+
+ATF_TC(erff_inf_neg);
+ATF_TC_HEAD(erff_inf_neg, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erff(-Inf) == -1.0");
+}
+
+ATF_TC_BODY(erff_inf_neg, tc)
+{
+#ifndef __vax__
+ const float x = -1.0L / 0.0L;
+
+ if (erff(x) != -1.0)
+ atf_tc_fail_nonfatal("erff(-Inf) != -1.0");
+#endif
+}
+
+ATF_TC(erff_inf_pos);
+ATF_TC_HEAD(erff_inf_pos, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erff(+Inf) == 1.0");
+}
+
+ATF_TC_BODY(erff_inf_pos, tc)
+{
+#ifndef __vax__
+ const float x = 1.0L / 0.0L;
+
+ if (erff(x) != 1.0)
+ atf_tc_fail_nonfatal("erff(+Inf) != 1.0");
+#endif
+}
+
+ATF_TC(erff_zero_neg);
+ATF_TC_HEAD(erff_zero_neg, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erff(-0.0) == -0.0");
+}
+
+ATF_TC_BODY(erff_zero_neg, tc)
+{
+#ifndef __vax__
+ const float x = -0.0L;
+ float y = erff(x);
+
+ if (fabsf(y) > 0.0 || signbit(y) == 0)
+ atf_tc_fail_nonfatal("erff(-0.0) != -0.0");
+#endif
+}
+
+ATF_TC(erff_zero_pos);
+ATF_TC_HEAD(erff_zero_pos, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erff(+0.0) == +0.0");
+}
+
+ATF_TC_BODY(erff_zero_pos, tc)
+{
+#ifndef __vax__
+ const float x = 0.0L;
+ float y = erff(x);
+
+ if (fabsf(y) > 0.0 || signbit(y) != 0)
+ atf_tc_fail_nonfatal("erff(+0.0) != +0.0");
+#endif
+}
+
+/*
+ * erfc(3)
+ */
+ATF_TC(erfc_nan);
+ATF_TC_HEAD(erfc_nan, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erfc(NaN) == NaN");
+}
+
+ATF_TC_BODY(erfc_nan, tc)
+{
+#ifndef __vax__
+ const double x = 0.0L / 0.0L;
+
+ ATF_CHECK(isnan(erfc(x)) != 0);
+#endif
+}
+
+ATF_TC(erfc_inf_neg);
+ATF_TC_HEAD(erfc_inf_neg, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erfc(-Inf) == 2.0");
+}
+
+ATF_TC_BODY(erfc_inf_neg, tc)
+{
+#ifndef __vax__
+ const double x = -1.0L / 0.0L;
+
+ if (erfc(x) != 2.0)
+ atf_tc_fail_nonfatal("erfc(-Inf) != 2.0");
+#endif
+}
+
+ATF_TC(erfc_inf_pos);
+ATF_TC_HEAD(erfc_inf_pos, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test erfc(+Inf) == +0.0");
+}
+
+ATF_TC_BODY(erfc_inf_pos, tc)
+{
+#ifndef __vax__
+ const double x = 1.0L / 0.0L;
+ double y = erfc(x);
+
+ if (fabs(y) > 0.0 || signbit(y) != 0)
+ atf_tc_fail_nonfatal("erfc(+Inf) != +0.0");
+#endif
+}
Home |
Main Index |
Thread Index |
Old Index