Merge 't_floor' to 't_ceil', and simplify.
This commit is contained in:
parent
1701dae929
commit
bfd4049668
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.383 2011/09/12 15:27:40 jruoho Exp $
|
||||
# $NetBSD: mi,v 1.384 2011/09/12 16:48:48 jruoho Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
|
@ -547,7 +547,7 @@
|
|||
./usr/libdata/debug/usr/tests/lib/libevent/h_event.debug tests-lib-debug debug,atf
|
||||
./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_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
|
||||
./usr/libdata/debug/usr/tests/lib/libm/t_log.debug tests-lib-debug debug,atf
|
||||
|
@ -2253,7 +2253,7 @@
|
|||
./usr/tests/lib/libm tests-lib-tests atf
|
||||
./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_floor tests-obsolete obsolete
|
||||
./usr/tests/lib/libm/t_infinity tests-lib-tests atf
|
||||
./usr/tests/lib/libm/t_ldexp tests-lib-tests atf
|
||||
./usr/tests/lib/libm/t_log tests-lib-tests atf
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
# $NetBSD: Makefile,v 1.7 2011/09/12 15:27:40 jruoho Exp $
|
||||
# $NetBSD: Makefile,v 1.8 2011/09/12 16:48:48 jruoho Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib/libm
|
||||
|
||||
TESTS_C+= t_ceil
|
||||
TESTS_C+= t_floor
|
||||
TESTS_C+= t_infinity
|
||||
TESTS_C+= t_ldexp
|
||||
TESTS_C+= t_log
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: t_ceil.c,v 1.4 2011/07/04 22:33:29 mrg Exp $ */
|
||||
/* $NetBSD: t_ceil.c,v 1.5 2011/09/12 16:48:48 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
|
@ -29,18 +29,12 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: t_ceil.c,v 1.4 2011/07/04 22:33:29 mrg Exp $");
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
__RCSID("$NetBSD: t_ceil.c,v 1.5 2011/09/12 16:48:48 jruoho Exp $");
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
ATF_TC(ceil);
|
||||
ATF_TC_HEAD(ceil, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "A basic test of ceil(3)");
|
||||
}
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __vax__
|
||||
#define SMALL_NUM 1.0e-38
|
||||
|
@ -48,25 +42,73 @@ ATF_TC_HEAD(ceil, tc)
|
|||
#define SMALL_NUM 1.0e-40
|
||||
#endif
|
||||
|
||||
ATF_TC_BODY(ceil, tc)
|
||||
ATF_TC(ceil_basic);
|
||||
ATF_TC_HEAD(ceil_basic, tc)
|
||||
{
|
||||
const int n = 10240;
|
||||
double x, y;
|
||||
int i;
|
||||
atf_tc_set_md_var(tc, "descr", "A basic test of ceil(3)");
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
ATF_TC_BODY(ceil_basic, tc)
|
||||
{
|
||||
const double x = 0.999999999999999;
|
||||
const double y = 0.000000000000001;
|
||||
|
||||
x = i + 0.999999999;
|
||||
y = i + 0.000000001;
|
||||
ATF_CHECK(fabs(ceil(x) - 1) < SMALL_NUM);
|
||||
ATF_CHECK(fabs(ceil(y) - 1) < SMALL_NUM);
|
||||
}
|
||||
|
||||
ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < SMALL_NUM);
|
||||
ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < SMALL_NUM);
|
||||
}
|
||||
ATF_TC(ceilf_basic);
|
||||
ATF_TC_HEAD(ceilf_basic, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "A basic test of ceilf(3)");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(ceilf_basic, tc)
|
||||
{
|
||||
const float x = 0.9999999;
|
||||
const float y = 0.0000001;
|
||||
|
||||
ATF_CHECK(fabsf(ceilf(x) - 1) < SMALL_NUM);
|
||||
ATF_CHECK(fabsf(ceilf(y) - 1) < SMALL_NUM);
|
||||
}
|
||||
|
||||
ATF_TC(floor_basic);
|
||||
ATF_TC_HEAD(floor_basic, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "A basic test of floor(3)");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(floor_basic, tc)
|
||||
{
|
||||
const double x = 0.999999999999999;
|
||||
const double y = 0.000000000000001;
|
||||
|
||||
ATF_CHECK(floor(x) < SMALL_NUM);
|
||||
ATF_CHECK(floor(y) < SMALL_NUM);
|
||||
}
|
||||
|
||||
ATF_TC(floorf_basic);
|
||||
ATF_TC_HEAD(floorf_basic, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "A basic test of floorf(3)");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(floorf_basic, tc)
|
||||
{
|
||||
const float x = 0.9999999;
|
||||
const float y = 0.0000001;
|
||||
|
||||
ATF_CHECK(floorf(x) < SMALL_NUM);
|
||||
ATF_CHECK(floorf(y) < SMALL_NUM);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, ceil);
|
||||
|
||||
ATF_TP_ADD_TC(tp, ceil_basic);
|
||||
ATF_TP_ADD_TC(tp, ceilf_basic);
|
||||
ATF_TP_ADD_TC(tp, floorf_basic);
|
||||
ATF_TP_ADD_TC(tp, floorf_basic);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
/* $NetBSD: t_floor.c,v 1.8 2011/08/29 17:39:54 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_floor.c,v 1.8 2011/08/29 17:39:54 jruoho Exp $");
|
||||
|
||||
#include <atf-c.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
ATF_TC(floor);
|
||||
ATF_TC_HEAD(floor, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "A basic test of floor(3)");
|
||||
}
|
||||
|
||||
#ifdef __vax__
|
||||
#define SMALL_NUM 1.0e-38
|
||||
#else
|
||||
#define SMALL_NUM 1.0e-40
|
||||
#endif
|
||||
|
||||
ATF_TC_BODY(floor, tc)
|
||||
{
|
||||
const int n = 10240;
|
||||
double x, y;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* This may fail under QEMU; see PR misc/44767.
|
||||
*/
|
||||
for (i = 0; i < n; i++) {
|
||||
|
||||
x = i + 0.999999999;
|
||||
y = i + 0.000000001;
|
||||
|
||||
ATF_REQUIRE(fabs(floor(x) - (double)i) < SMALL_NUM);
|
||||
ATF_REQUIRE(fabs(floor(y) - (double)i) < SMALL_NUM);
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, floor);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
Loading…
Reference in New Issue