xref: /minix3/tests/lib/libm/t_ceil.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /* $NetBSD: t_ceil.c,v 1.10 2014/03/03 10:39:08 martin Exp $ */
211be35a1SLionel Sambuc 
311be35a1SLionel Sambuc /*-
411be35a1SLionel Sambuc  * Copyright (c) 2011 The NetBSD Foundation, Inc.
511be35a1SLionel Sambuc  * All rights reserved.
611be35a1SLionel Sambuc  *
711be35a1SLionel Sambuc  * This code is derived from software contributed to The NetBSD Foundation
811be35a1SLionel Sambuc  * by Jukka Ruohonen.
911be35a1SLionel Sambuc  *
1011be35a1SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
1111be35a1SLionel Sambuc  * modification, are permitted provided that the following conditions
1211be35a1SLionel Sambuc  * are met:
1311be35a1SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
1411be35a1SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
1511be35a1SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
1611be35a1SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
1711be35a1SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
1811be35a1SLionel Sambuc  *
1911be35a1SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2011be35a1SLionel Sambuc  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2111be35a1SLionel Sambuc  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2211be35a1SLionel Sambuc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2311be35a1SLionel Sambuc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2411be35a1SLionel Sambuc  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2511be35a1SLionel Sambuc  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2611be35a1SLionel Sambuc  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2711be35a1SLionel Sambuc  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2811be35a1SLionel Sambuc  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2911be35a1SLionel Sambuc  * POSSIBILITY OF SUCH DAMAGE.
3011be35a1SLionel Sambuc  */
3111be35a1SLionel Sambuc #include <sys/cdefs.h>
32*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: t_ceil.c,v 1.10 2014/03/03 10:39:08 martin Exp $");
3311be35a1SLionel Sambuc 
3411be35a1SLionel Sambuc #include <atf-c.h>
3511be35a1SLionel Sambuc #include <math.h>
3611be35a1SLionel Sambuc #include <limits.h>
3711be35a1SLionel Sambuc #include <stdio.h>
3811be35a1SLionel Sambuc 
3911be35a1SLionel Sambuc #ifdef __vax__
4011be35a1SLionel Sambuc #define SMALL_NUM	1.0e-38
4111be35a1SLionel Sambuc #else
4211be35a1SLionel Sambuc #define SMALL_NUM	1.0e-40
4311be35a1SLionel Sambuc #endif
4411be35a1SLionel Sambuc 
4511be35a1SLionel Sambuc /*
4611be35a1SLionel Sambuc  * ceil(3)
4711be35a1SLionel Sambuc  */
4811be35a1SLionel Sambuc ATF_TC(ceil_basic);
ATF_TC_HEAD(ceil_basic,tc)4911be35a1SLionel Sambuc ATF_TC_HEAD(ceil_basic, tc)
5011be35a1SLionel Sambuc {
5111be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "A basic test of ceil(3)");
5211be35a1SLionel Sambuc }
5311be35a1SLionel Sambuc 
ATF_TC_BODY(ceil_basic,tc)5411be35a1SLionel Sambuc ATF_TC_BODY(ceil_basic, tc)
5511be35a1SLionel Sambuc {
5611be35a1SLionel Sambuc 	const double x = 0.999999999999999;
5711be35a1SLionel Sambuc 	const double y = 0.000000000000001;
5811be35a1SLionel Sambuc 
5911be35a1SLionel Sambuc 	ATF_CHECK(fabs(ceil(x) - 1) < SMALL_NUM);
6011be35a1SLionel Sambuc 	ATF_CHECK(fabs(ceil(y) - 1) < SMALL_NUM);
6111be35a1SLionel Sambuc }
6211be35a1SLionel Sambuc 
6311be35a1SLionel Sambuc ATF_TC(ceil_nan);
ATF_TC_HEAD(ceil_nan,tc)6411be35a1SLionel Sambuc ATF_TC_HEAD(ceil_nan, tc)
6511be35a1SLionel Sambuc {
6611be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceil(NaN) == NaN");
6711be35a1SLionel Sambuc }
6811be35a1SLionel Sambuc 
ATF_TC_BODY(ceil_nan,tc)6911be35a1SLionel Sambuc ATF_TC_BODY(ceil_nan, tc)
7011be35a1SLionel Sambuc {
7111be35a1SLionel Sambuc 	const double x = 0.0L / 0.0L;
7211be35a1SLionel Sambuc 
7311be35a1SLionel Sambuc 	ATF_CHECK(isnan(ceil(x)) != 0);
7411be35a1SLionel Sambuc }
7511be35a1SLionel Sambuc 
7611be35a1SLionel Sambuc ATF_TC(ceil_inf_neg);
ATF_TC_HEAD(ceil_inf_neg,tc)7711be35a1SLionel Sambuc ATF_TC_HEAD(ceil_inf_neg, tc)
7811be35a1SLionel Sambuc {
7911be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceil(-Inf) == -Inf");
8011be35a1SLionel Sambuc }
8111be35a1SLionel Sambuc 
ATF_TC_BODY(ceil_inf_neg,tc)8211be35a1SLionel Sambuc ATF_TC_BODY(ceil_inf_neg, tc)
8311be35a1SLionel Sambuc {
8411be35a1SLionel Sambuc 	const double x = -1.0L / 0.0L;
8511be35a1SLionel Sambuc 	double y = ceil(x);
8611be35a1SLionel Sambuc 
8711be35a1SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) == 0)
8811be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("ceil(-Inf) != -Inf");
8911be35a1SLionel Sambuc }
9011be35a1SLionel Sambuc 
9111be35a1SLionel Sambuc ATF_TC(ceil_inf_pos);
ATF_TC_HEAD(ceil_inf_pos,tc)9211be35a1SLionel Sambuc ATF_TC_HEAD(ceil_inf_pos, tc)
9311be35a1SLionel Sambuc {
9411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceil(+Inf) == +Inf");
9511be35a1SLionel Sambuc }
9611be35a1SLionel Sambuc 
ATF_TC_BODY(ceil_inf_pos,tc)9711be35a1SLionel Sambuc ATF_TC_BODY(ceil_inf_pos, tc)
9811be35a1SLionel Sambuc {
9911be35a1SLionel Sambuc 	const double x = 1.0L / 0.0L;
10011be35a1SLionel Sambuc 	double y = ceil(x);
10111be35a1SLionel Sambuc 
10211be35a1SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) != 0)
10311be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("ceil(+Inf) != +Inf");
10411be35a1SLionel Sambuc }
10511be35a1SLionel Sambuc 
10611be35a1SLionel Sambuc ATF_TC(ceil_zero_neg);
ATF_TC_HEAD(ceil_zero_neg,tc)10711be35a1SLionel Sambuc ATF_TC_HEAD(ceil_zero_neg, tc)
10811be35a1SLionel Sambuc {
10911be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceil(-0.0) == -0.0");
11011be35a1SLionel Sambuc }
11111be35a1SLionel Sambuc 
ATF_TC_BODY(ceil_zero_neg,tc)11211be35a1SLionel Sambuc ATF_TC_BODY(ceil_zero_neg, tc)
11311be35a1SLionel Sambuc {
11411be35a1SLionel Sambuc 	const double x = -0.0L;
11511be35a1SLionel Sambuc 	double y = ceil(x);
11611be35a1SLionel Sambuc 
11711be35a1SLionel Sambuc 	if (fabs(y) > 0.0 || signbit(y) == 0)
11811be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("ceil(-0.0) != -0.0");
11911be35a1SLionel Sambuc }
12011be35a1SLionel Sambuc 
12111be35a1SLionel Sambuc ATF_TC(ceil_zero_pos);
ATF_TC_HEAD(ceil_zero_pos,tc)12211be35a1SLionel Sambuc ATF_TC_HEAD(ceil_zero_pos, tc)
12311be35a1SLionel Sambuc {
12411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceil(+0.0) == +0.0");
12511be35a1SLionel Sambuc }
12611be35a1SLionel Sambuc 
ATF_TC_BODY(ceil_zero_pos,tc)12711be35a1SLionel Sambuc ATF_TC_BODY(ceil_zero_pos, tc)
12811be35a1SLionel Sambuc {
12911be35a1SLionel Sambuc 	const double x = 0.0L;
13011be35a1SLionel Sambuc 	double y = ceil(x);
13111be35a1SLionel Sambuc 
13211be35a1SLionel Sambuc 	if (fabs(y) > 0.0 || signbit(y) != 0)
13311be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("ceil(+0.0) != +0.0");
13411be35a1SLionel Sambuc }
13511be35a1SLionel Sambuc 
13611be35a1SLionel Sambuc /*
13711be35a1SLionel Sambuc  * ceilf(3)
13811be35a1SLionel Sambuc  */
13911be35a1SLionel Sambuc ATF_TC(ceilf_basic);
ATF_TC_HEAD(ceilf_basic,tc)14011be35a1SLionel Sambuc ATF_TC_HEAD(ceilf_basic, tc)
14111be35a1SLionel Sambuc {
14211be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "A basic test of ceilf(3)");
14311be35a1SLionel Sambuc }
14411be35a1SLionel Sambuc 
ATF_TC_BODY(ceilf_basic,tc)14511be35a1SLionel Sambuc ATF_TC_BODY(ceilf_basic, tc)
14611be35a1SLionel Sambuc {
14711be35a1SLionel Sambuc 	const float x = 0.9999999;
14811be35a1SLionel Sambuc 	const float y = 0.0000001;
14911be35a1SLionel Sambuc 
15011be35a1SLionel Sambuc 	ATF_CHECK(fabsf(ceilf(x) - 1) < SMALL_NUM);
15111be35a1SLionel Sambuc 	ATF_CHECK(fabsf(ceilf(y) - 1) < SMALL_NUM);
15211be35a1SLionel Sambuc }
15311be35a1SLionel Sambuc 
15411be35a1SLionel Sambuc ATF_TC(ceilf_nan);
ATF_TC_HEAD(ceilf_nan,tc)15511be35a1SLionel Sambuc ATF_TC_HEAD(ceilf_nan, tc)
15611be35a1SLionel Sambuc {
15711be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceilf(NaN) == NaN");
15811be35a1SLionel Sambuc }
15911be35a1SLionel Sambuc 
ATF_TC_BODY(ceilf_nan,tc)16011be35a1SLionel Sambuc ATF_TC_BODY(ceilf_nan, tc)
16111be35a1SLionel Sambuc {
16211be35a1SLionel Sambuc 	const float x = 0.0L / 0.0L;
16311be35a1SLionel Sambuc 
16411be35a1SLionel Sambuc 	ATF_CHECK(isnan(ceilf(x)) != 0);
16511be35a1SLionel Sambuc }
16611be35a1SLionel Sambuc 
16711be35a1SLionel Sambuc ATF_TC(ceilf_inf_neg);
ATF_TC_HEAD(ceilf_inf_neg,tc)16811be35a1SLionel Sambuc ATF_TC_HEAD(ceilf_inf_neg, tc)
16911be35a1SLionel Sambuc {
17011be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceilf(-Inf) == -Inf");
17111be35a1SLionel Sambuc }
17211be35a1SLionel Sambuc 
ATF_TC_BODY(ceilf_inf_neg,tc)17311be35a1SLionel Sambuc ATF_TC_BODY(ceilf_inf_neg, tc)
17411be35a1SLionel Sambuc {
17511be35a1SLionel Sambuc 	const float x = -1.0L / 0.0L;
17611be35a1SLionel Sambuc 	float y = ceilf(x);
17711be35a1SLionel Sambuc 
17811be35a1SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) == 0)
17911be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("ceilf(-Inf) != -Inf");
18011be35a1SLionel Sambuc }
18111be35a1SLionel Sambuc 
18211be35a1SLionel Sambuc ATF_TC(ceilf_inf_pos);
ATF_TC_HEAD(ceilf_inf_pos,tc)18311be35a1SLionel Sambuc ATF_TC_HEAD(ceilf_inf_pos, tc)
18411be35a1SLionel Sambuc {
18511be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceilf(+Inf) == +Inf");
18611be35a1SLionel Sambuc }
18711be35a1SLionel Sambuc 
ATF_TC_BODY(ceilf_inf_pos,tc)18811be35a1SLionel Sambuc ATF_TC_BODY(ceilf_inf_pos, tc)
18911be35a1SLionel Sambuc {
19011be35a1SLionel Sambuc 	const float x = 1.0L / 0.0L;
19111be35a1SLionel Sambuc 	float y = ceilf(x);
19211be35a1SLionel Sambuc 
19311be35a1SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) != 0)
19411be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("ceilf(+Inf) != +Inf");
19511be35a1SLionel Sambuc }
19611be35a1SLionel Sambuc 
19711be35a1SLionel Sambuc ATF_TC(ceilf_zero_neg);
ATF_TC_HEAD(ceilf_zero_neg,tc)19811be35a1SLionel Sambuc ATF_TC_HEAD(ceilf_zero_neg, tc)
19911be35a1SLionel Sambuc {
20011be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceilf(-0.0) == -0.0");
20111be35a1SLionel Sambuc }
20211be35a1SLionel Sambuc 
ATF_TC_BODY(ceilf_zero_neg,tc)20311be35a1SLionel Sambuc ATF_TC_BODY(ceilf_zero_neg, tc)
20411be35a1SLionel Sambuc {
20511be35a1SLionel Sambuc 	const float x = -0.0L;
20611be35a1SLionel Sambuc 	float y = ceilf(x);
20711be35a1SLionel Sambuc 
20811be35a1SLionel Sambuc 	if (fabsf(y) > 0.0 || signbit(y) == 0)
20911be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("ceilf(-0.0) != -0.0");
21011be35a1SLionel Sambuc }
21111be35a1SLionel Sambuc 
21211be35a1SLionel Sambuc ATF_TC(ceilf_zero_pos);
ATF_TC_HEAD(ceilf_zero_pos,tc)21311be35a1SLionel Sambuc ATF_TC_HEAD(ceilf_zero_pos, tc)
21411be35a1SLionel Sambuc {
21511be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceilf(+0.0) == +0.0");
21611be35a1SLionel Sambuc }
21711be35a1SLionel Sambuc 
ATF_TC_BODY(ceilf_zero_pos,tc)21811be35a1SLionel Sambuc ATF_TC_BODY(ceilf_zero_pos, tc)
21911be35a1SLionel Sambuc {
22011be35a1SLionel Sambuc 	const float x = 0.0L;
22111be35a1SLionel Sambuc 	float y = ceilf(x);
22211be35a1SLionel Sambuc 
22311be35a1SLionel Sambuc 	if (fabsf(y) > 0.0 || signbit(y) != 0)
22411be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("ceilf(+0.0) != +0.0");
22511be35a1SLionel Sambuc }
22611be35a1SLionel Sambuc 
22711be35a1SLionel Sambuc /*
22884d9c625SLionel Sambuc  * ceill(3)
22984d9c625SLionel Sambuc  */
23084d9c625SLionel Sambuc ATF_TC(ceill_basic);
ATF_TC_HEAD(ceill_basic,tc)23184d9c625SLionel Sambuc ATF_TC_HEAD(ceill_basic, tc)
23284d9c625SLionel Sambuc {
23384d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "A basic test of ceill(3)");
23484d9c625SLionel Sambuc }
23584d9c625SLionel Sambuc 
ATF_TC_BODY(ceill_basic,tc)23684d9c625SLionel Sambuc ATF_TC_BODY(ceill_basic, tc)
23784d9c625SLionel Sambuc {
23884d9c625SLionel Sambuc 	const long double x = 0.9999999;
23984d9c625SLionel Sambuc 	const long double y = 0.0000001;
24084d9c625SLionel Sambuc 
24184d9c625SLionel Sambuc 	ATF_CHECK(fabsl(ceill(x) - 1) < SMALL_NUM);
24284d9c625SLionel Sambuc 	ATF_CHECK(fabsl(ceill(y) - 1) < SMALL_NUM);
24384d9c625SLionel Sambuc }
24484d9c625SLionel Sambuc 
24584d9c625SLionel Sambuc ATF_TC(ceill_nan);
ATF_TC_HEAD(ceill_nan,tc)24684d9c625SLionel Sambuc ATF_TC_HEAD(ceill_nan, tc)
24784d9c625SLionel Sambuc {
24884d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceill(NaN) == NaN");
24984d9c625SLionel Sambuc }
25084d9c625SLionel Sambuc 
ATF_TC_BODY(ceill_nan,tc)25184d9c625SLionel Sambuc ATF_TC_BODY(ceill_nan, tc)
25284d9c625SLionel Sambuc {
25384d9c625SLionel Sambuc 	const long double x = 0.0L / 0.0L;
25484d9c625SLionel Sambuc 
25584d9c625SLionel Sambuc 	ATF_CHECK(isnan(ceill(x)) != 0);
25684d9c625SLionel Sambuc }
25784d9c625SLionel Sambuc 
25884d9c625SLionel Sambuc ATF_TC(ceill_inf_neg);
ATF_TC_HEAD(ceill_inf_neg,tc)25984d9c625SLionel Sambuc ATF_TC_HEAD(ceill_inf_neg, tc)
26084d9c625SLionel Sambuc {
26184d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceill(-Inf) == -Inf");
26284d9c625SLionel Sambuc }
26384d9c625SLionel Sambuc 
ATF_TC_BODY(ceill_inf_neg,tc)26484d9c625SLionel Sambuc ATF_TC_BODY(ceill_inf_neg, tc)
26584d9c625SLionel Sambuc {
26684d9c625SLionel Sambuc 	const long double x = -1.0L / 0.0L;
26784d9c625SLionel Sambuc 	long double y = ceill(x);
26884d9c625SLionel Sambuc 
26984d9c625SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) == 0)
27084d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("ceill(-Inf) != -Inf");
27184d9c625SLionel Sambuc }
27284d9c625SLionel Sambuc 
27384d9c625SLionel Sambuc ATF_TC(ceill_inf_pos);
ATF_TC_HEAD(ceill_inf_pos,tc)27484d9c625SLionel Sambuc ATF_TC_HEAD(ceill_inf_pos, tc)
27584d9c625SLionel Sambuc {
27684d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceill(+Inf) == +Inf");
27784d9c625SLionel Sambuc }
27884d9c625SLionel Sambuc 
ATF_TC_BODY(ceill_inf_pos,tc)27984d9c625SLionel Sambuc ATF_TC_BODY(ceill_inf_pos, tc)
28084d9c625SLionel Sambuc {
28184d9c625SLionel Sambuc 	const long double x = 1.0L / 0.0L;
28284d9c625SLionel Sambuc 	long double y = ceill(x);
28384d9c625SLionel Sambuc 
28484d9c625SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) != 0)
28584d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("ceill(+Inf) != +Inf");
28684d9c625SLionel Sambuc }
28784d9c625SLionel Sambuc 
28884d9c625SLionel Sambuc ATF_TC(ceill_zero_neg);
ATF_TC_HEAD(ceill_zero_neg,tc)28984d9c625SLionel Sambuc ATF_TC_HEAD(ceill_zero_neg, tc)
29084d9c625SLionel Sambuc {
29184d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceill(-0.0) == -0.0");
29284d9c625SLionel Sambuc }
29384d9c625SLionel Sambuc 
ATF_TC_BODY(ceill_zero_neg,tc)29484d9c625SLionel Sambuc ATF_TC_BODY(ceill_zero_neg, tc)
29584d9c625SLionel Sambuc {
29684d9c625SLionel Sambuc 	const long double x = -0.0L;
29784d9c625SLionel Sambuc 	long double y = ceill(x);
29884d9c625SLionel Sambuc 
29984d9c625SLionel Sambuc 	if (fabsl(y) > 0.0 || signbit(y) == 0)
30084d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("ceill(-0.0) != -0.0");
30184d9c625SLionel Sambuc }
30284d9c625SLionel Sambuc 
30384d9c625SLionel Sambuc ATF_TC(ceill_zero_pos);
ATF_TC_HEAD(ceill_zero_pos,tc)30484d9c625SLionel Sambuc ATF_TC_HEAD(ceill_zero_pos, tc)
30584d9c625SLionel Sambuc {
30684d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test ceill(+0.0) == +0.0");
30784d9c625SLionel Sambuc }
30884d9c625SLionel Sambuc 
ATF_TC_BODY(ceill_zero_pos,tc)30984d9c625SLionel Sambuc ATF_TC_BODY(ceill_zero_pos, tc)
31084d9c625SLionel Sambuc {
31184d9c625SLionel Sambuc 	const long double x = 0.0L;
31284d9c625SLionel Sambuc 	long double y = ceill(x);
31384d9c625SLionel Sambuc 
31484d9c625SLionel Sambuc 	if (fabsl(y) > 0.0 || signbit(y) != 0)
31584d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("ceill(+0.0) != +0.0");
31684d9c625SLionel Sambuc }
31784d9c625SLionel Sambuc 
31884d9c625SLionel Sambuc /*
31911be35a1SLionel Sambuc  * floor(3)
32011be35a1SLionel Sambuc  */
32111be35a1SLionel Sambuc ATF_TC(floor_basic);
ATF_TC_HEAD(floor_basic,tc)32211be35a1SLionel Sambuc ATF_TC_HEAD(floor_basic, tc)
32311be35a1SLionel Sambuc {
32411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "A basic test of floor(3)");
32511be35a1SLionel Sambuc }
32611be35a1SLionel Sambuc 
ATF_TC_BODY(floor_basic,tc)32711be35a1SLionel Sambuc ATF_TC_BODY(floor_basic, tc)
32811be35a1SLionel Sambuc {
32911be35a1SLionel Sambuc 	const double x = 0.999999999999999;
33011be35a1SLionel Sambuc 	const double y = 0.000000000000001;
33111be35a1SLionel Sambuc 
33211be35a1SLionel Sambuc 	ATF_CHECK(floor(x) < SMALL_NUM);
33311be35a1SLionel Sambuc 	ATF_CHECK(floor(y) < SMALL_NUM);
33411be35a1SLionel Sambuc }
33511be35a1SLionel Sambuc 
33611be35a1SLionel Sambuc ATF_TC(floor_nan);
ATF_TC_HEAD(floor_nan,tc)33711be35a1SLionel Sambuc ATF_TC_HEAD(floor_nan, tc)
33811be35a1SLionel Sambuc {
33911be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floor(NaN) == NaN");
34011be35a1SLionel Sambuc }
34111be35a1SLionel Sambuc 
ATF_TC_BODY(floor_nan,tc)34211be35a1SLionel Sambuc ATF_TC_BODY(floor_nan, tc)
34311be35a1SLionel Sambuc {
34411be35a1SLionel Sambuc 	const double x = 0.0L / 0.0L;
34511be35a1SLionel Sambuc 
34611be35a1SLionel Sambuc 	ATF_CHECK(isnan(floor(x)) != 0);
34711be35a1SLionel Sambuc }
34811be35a1SLionel Sambuc 
34911be35a1SLionel Sambuc ATF_TC(floor_inf_neg);
ATF_TC_HEAD(floor_inf_neg,tc)35011be35a1SLionel Sambuc ATF_TC_HEAD(floor_inf_neg, tc)
35111be35a1SLionel Sambuc {
35211be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floor(-Inf) == -Inf");
35311be35a1SLionel Sambuc }
35411be35a1SLionel Sambuc 
ATF_TC_BODY(floor_inf_neg,tc)35511be35a1SLionel Sambuc ATF_TC_BODY(floor_inf_neg, tc)
35611be35a1SLionel Sambuc {
35711be35a1SLionel Sambuc 	const double x = -1.0L / 0.0L;
35811be35a1SLionel Sambuc 	double y = floor(x);
35911be35a1SLionel Sambuc 
36011be35a1SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) == 0)
36111be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("floor(-Inf) != -Inf");
36211be35a1SLionel Sambuc }
36311be35a1SLionel Sambuc 
36411be35a1SLionel Sambuc ATF_TC(floor_inf_pos);
ATF_TC_HEAD(floor_inf_pos,tc)36511be35a1SLionel Sambuc ATF_TC_HEAD(floor_inf_pos, tc)
36611be35a1SLionel Sambuc {
36711be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floor(+Inf) == +Inf");
36811be35a1SLionel Sambuc }
36911be35a1SLionel Sambuc 
ATF_TC_BODY(floor_inf_pos,tc)37011be35a1SLionel Sambuc ATF_TC_BODY(floor_inf_pos, tc)
37111be35a1SLionel Sambuc {
37211be35a1SLionel Sambuc 	const double x = 1.0L / 0.0L;
37311be35a1SLionel Sambuc 	double y = floor(x);
37411be35a1SLionel Sambuc 
37511be35a1SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) != 0)
37611be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("floor(+Inf) != +Inf");
37711be35a1SLionel Sambuc }
37811be35a1SLionel Sambuc 
37911be35a1SLionel Sambuc ATF_TC(floor_zero_neg);
ATF_TC_HEAD(floor_zero_neg,tc)38011be35a1SLionel Sambuc ATF_TC_HEAD(floor_zero_neg, tc)
38111be35a1SLionel Sambuc {
38211be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floor(-0.0) == -0.0");
38311be35a1SLionel Sambuc }
38411be35a1SLionel Sambuc 
ATF_TC_BODY(floor_zero_neg,tc)38511be35a1SLionel Sambuc ATF_TC_BODY(floor_zero_neg, tc)
38611be35a1SLionel Sambuc {
38711be35a1SLionel Sambuc 	const double x = -0.0L;
38811be35a1SLionel Sambuc 	double y = floor(x);
38911be35a1SLionel Sambuc 
39011be35a1SLionel Sambuc 	if (fabs(y) > 0.0 || signbit(y) == 0)
39111be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("floor(-0.0) != -0.0");
39211be35a1SLionel Sambuc }
39311be35a1SLionel Sambuc 
39411be35a1SLionel Sambuc ATF_TC(floor_zero_pos);
ATF_TC_HEAD(floor_zero_pos,tc)39511be35a1SLionel Sambuc ATF_TC_HEAD(floor_zero_pos, tc)
39611be35a1SLionel Sambuc {
39711be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floor(+0.0) == +0.0");
39811be35a1SLionel Sambuc }
39911be35a1SLionel Sambuc 
ATF_TC_BODY(floor_zero_pos,tc)40011be35a1SLionel Sambuc ATF_TC_BODY(floor_zero_pos, tc)
40111be35a1SLionel Sambuc {
40211be35a1SLionel Sambuc 	const double x = 0.0L;
40311be35a1SLionel Sambuc 	double y = floor(x);
40411be35a1SLionel Sambuc 
40511be35a1SLionel Sambuc 	if (fabs(y) > 0.0 || signbit(y) != 0)
40611be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("floor(+0.0) != +0.0");
40711be35a1SLionel Sambuc }
40811be35a1SLionel Sambuc 
40911be35a1SLionel Sambuc /*
41011be35a1SLionel Sambuc  * floorf(3)
41111be35a1SLionel Sambuc  */
41211be35a1SLionel Sambuc ATF_TC(floorf_basic);
ATF_TC_HEAD(floorf_basic,tc)41311be35a1SLionel Sambuc ATF_TC_HEAD(floorf_basic, tc)
41411be35a1SLionel Sambuc {
41511be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "A basic test of floorf(3)");
41611be35a1SLionel Sambuc }
41711be35a1SLionel Sambuc 
ATF_TC_BODY(floorf_basic,tc)41811be35a1SLionel Sambuc ATF_TC_BODY(floorf_basic, tc)
41911be35a1SLionel Sambuc {
42011be35a1SLionel Sambuc 	const float x = 0.9999999;
42111be35a1SLionel Sambuc 	const float y = 0.0000001;
42211be35a1SLionel Sambuc 
42311be35a1SLionel Sambuc 	ATF_CHECK(floorf(x) < SMALL_NUM);
42411be35a1SLionel Sambuc 	ATF_CHECK(floorf(y) < SMALL_NUM);
42511be35a1SLionel Sambuc }
42611be35a1SLionel Sambuc 
42711be35a1SLionel Sambuc ATF_TC(floorf_nan);
ATF_TC_HEAD(floorf_nan,tc)42811be35a1SLionel Sambuc ATF_TC_HEAD(floorf_nan, tc)
42911be35a1SLionel Sambuc {
43011be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floorf(NaN) == NaN");
43111be35a1SLionel Sambuc }
43211be35a1SLionel Sambuc 
ATF_TC_BODY(floorf_nan,tc)43311be35a1SLionel Sambuc ATF_TC_BODY(floorf_nan, tc)
43411be35a1SLionel Sambuc {
43511be35a1SLionel Sambuc 	const float x = 0.0L / 0.0L;
43611be35a1SLionel Sambuc 
43711be35a1SLionel Sambuc 	ATF_CHECK(isnan(floorf(x)) != 0);
43811be35a1SLionel Sambuc }
43911be35a1SLionel Sambuc 
44011be35a1SLionel Sambuc ATF_TC(floorf_inf_neg);
ATF_TC_HEAD(floorf_inf_neg,tc)44111be35a1SLionel Sambuc ATF_TC_HEAD(floorf_inf_neg, tc)
44211be35a1SLionel Sambuc {
44311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floorf(-Inf) == -Inf");
44411be35a1SLionel Sambuc }
44511be35a1SLionel Sambuc 
ATF_TC_BODY(floorf_inf_neg,tc)44611be35a1SLionel Sambuc ATF_TC_BODY(floorf_inf_neg, tc)
44711be35a1SLionel Sambuc {
44811be35a1SLionel Sambuc 	const float x = -1.0L / 0.0L;
44911be35a1SLionel Sambuc 	float y = floorf(x);
45011be35a1SLionel Sambuc 
45111be35a1SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) == 0)
45211be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("floorf(-Inf) != -Inf");
45311be35a1SLionel Sambuc }
45411be35a1SLionel Sambuc 
45511be35a1SLionel Sambuc ATF_TC(floorf_inf_pos);
ATF_TC_HEAD(floorf_inf_pos,tc)45611be35a1SLionel Sambuc ATF_TC_HEAD(floorf_inf_pos, tc)
45711be35a1SLionel Sambuc {
45811be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floorf(+Inf) == +Inf");
45911be35a1SLionel Sambuc }
46011be35a1SLionel Sambuc 
ATF_TC_BODY(floorf_inf_pos,tc)46111be35a1SLionel Sambuc ATF_TC_BODY(floorf_inf_pos, tc)
46211be35a1SLionel Sambuc {
46311be35a1SLionel Sambuc 	const float x = 1.0L / 0.0L;
46411be35a1SLionel Sambuc 	float y = floorf(x);
46511be35a1SLionel Sambuc 
46611be35a1SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) != 0)
46711be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("floorf(+Inf) != +Inf");
46811be35a1SLionel Sambuc }
46911be35a1SLionel Sambuc 
47011be35a1SLionel Sambuc ATF_TC(floorf_zero_neg);
ATF_TC_HEAD(floorf_zero_neg,tc)47111be35a1SLionel Sambuc ATF_TC_HEAD(floorf_zero_neg, tc)
47211be35a1SLionel Sambuc {
47311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floorf(-0.0) == -0.0");
47411be35a1SLionel Sambuc }
47511be35a1SLionel Sambuc 
ATF_TC_BODY(floorf_zero_neg,tc)47611be35a1SLionel Sambuc ATF_TC_BODY(floorf_zero_neg, tc)
47711be35a1SLionel Sambuc {
47811be35a1SLionel Sambuc 	const float x = -0.0L;
47911be35a1SLionel Sambuc 	float y = floorf(x);
48011be35a1SLionel Sambuc 
48111be35a1SLionel Sambuc 	if (fabsf(y) > 0.0 || signbit(y) == 0)
48211be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("floorf(-0.0) != -0.0");
48311be35a1SLionel Sambuc }
48411be35a1SLionel Sambuc 
48511be35a1SLionel Sambuc ATF_TC(floorf_zero_pos);
ATF_TC_HEAD(floorf_zero_pos,tc)48611be35a1SLionel Sambuc ATF_TC_HEAD(floorf_zero_pos, tc)
48711be35a1SLionel Sambuc {
48811be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floorf(+0.0) == +0.0");
48911be35a1SLionel Sambuc }
49011be35a1SLionel Sambuc 
ATF_TC_BODY(floorf_zero_pos,tc)49111be35a1SLionel Sambuc ATF_TC_BODY(floorf_zero_pos, tc)
49211be35a1SLionel Sambuc {
49311be35a1SLionel Sambuc 	const float x = 0.0L;
49411be35a1SLionel Sambuc 	float y = floorf(x);
49511be35a1SLionel Sambuc 
49611be35a1SLionel Sambuc 	if (fabsf(y) > 0.0 || signbit(y) != 0)
49711be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("floorf(+0.0) != +0.0");
49811be35a1SLionel Sambuc }
49911be35a1SLionel Sambuc 
50084d9c625SLionel Sambuc /*
50184d9c625SLionel Sambuc  * floorl(3)
50284d9c625SLionel Sambuc  */
50384d9c625SLionel Sambuc ATF_TC(floorl_basic);
ATF_TC_HEAD(floorl_basic,tc)50484d9c625SLionel Sambuc ATF_TC_HEAD(floorl_basic, tc)
50584d9c625SLionel Sambuc {
50684d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "A basic test of floorl(3)");
50784d9c625SLionel Sambuc }
50884d9c625SLionel Sambuc 
ATF_TC_BODY(floorl_basic,tc)50984d9c625SLionel Sambuc ATF_TC_BODY(floorl_basic, tc)
51084d9c625SLionel Sambuc {
51184d9c625SLionel Sambuc 	const long double x = 0.9999999;
51284d9c625SLionel Sambuc 	const long double y = 0.0000001;
51384d9c625SLionel Sambuc 
51484d9c625SLionel Sambuc 	ATF_CHECK(floorl(x) < SMALL_NUM);
51584d9c625SLionel Sambuc 	ATF_CHECK(floorl(y) < SMALL_NUM);
51684d9c625SLionel Sambuc }
51784d9c625SLionel Sambuc 
51884d9c625SLionel Sambuc ATF_TC(floorl_nan);
ATF_TC_HEAD(floorl_nan,tc)51984d9c625SLionel Sambuc ATF_TC_HEAD(floorl_nan, tc)
52084d9c625SLionel Sambuc {
52184d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floorl(NaN) == NaN");
52284d9c625SLionel Sambuc }
52384d9c625SLionel Sambuc 
ATF_TC_BODY(floorl_nan,tc)52484d9c625SLionel Sambuc ATF_TC_BODY(floorl_nan, tc)
52584d9c625SLionel Sambuc {
52684d9c625SLionel Sambuc 	const long double x = 0.0L / 0.0L;
52784d9c625SLionel Sambuc 
52884d9c625SLionel Sambuc 	ATF_CHECK(isnan(floorl(x)) != 0);
52984d9c625SLionel Sambuc }
53084d9c625SLionel Sambuc 
53184d9c625SLionel Sambuc ATF_TC(floorl_inf_neg);
ATF_TC_HEAD(floorl_inf_neg,tc)53284d9c625SLionel Sambuc ATF_TC_HEAD(floorl_inf_neg, tc)
53384d9c625SLionel Sambuc {
53484d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floorl(-Inf) == -Inf");
53584d9c625SLionel Sambuc }
53684d9c625SLionel Sambuc 
ATF_TC_BODY(floorl_inf_neg,tc)53784d9c625SLionel Sambuc ATF_TC_BODY(floorl_inf_neg, tc)
53884d9c625SLionel Sambuc {
53984d9c625SLionel Sambuc 	const long double x = -1.0L / 0.0L;
54084d9c625SLionel Sambuc 	long double y = floorl(x);
54184d9c625SLionel Sambuc 
54284d9c625SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) == 0)
54384d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("floorl(-Inf) != -Inf");
54484d9c625SLionel Sambuc }
54584d9c625SLionel Sambuc 
54684d9c625SLionel Sambuc ATF_TC(floorl_inf_pos);
ATF_TC_HEAD(floorl_inf_pos,tc)54784d9c625SLionel Sambuc ATF_TC_HEAD(floorl_inf_pos, tc)
54884d9c625SLionel Sambuc {
54984d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floorl(+Inf) == +Inf");
55084d9c625SLionel Sambuc }
55184d9c625SLionel Sambuc 
ATF_TC_BODY(floorl_inf_pos,tc)55284d9c625SLionel Sambuc ATF_TC_BODY(floorl_inf_pos, tc)
55384d9c625SLionel Sambuc {
55484d9c625SLionel Sambuc 	const long double x = 1.0L / 0.0L;
55584d9c625SLionel Sambuc 	long double y = floorl(x);
55684d9c625SLionel Sambuc 
55784d9c625SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) != 0)
55884d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("floorl(+Inf) != +Inf");
55984d9c625SLionel Sambuc }
56084d9c625SLionel Sambuc 
56184d9c625SLionel Sambuc ATF_TC(floorl_zero_neg);
ATF_TC_HEAD(floorl_zero_neg,tc)56284d9c625SLionel Sambuc ATF_TC_HEAD(floorl_zero_neg, tc)
56384d9c625SLionel Sambuc {
56484d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floorl(-0.0) == -0.0");
56584d9c625SLionel Sambuc }
56684d9c625SLionel Sambuc 
ATF_TC_BODY(floorl_zero_neg,tc)56784d9c625SLionel Sambuc ATF_TC_BODY(floorl_zero_neg, tc)
56884d9c625SLionel Sambuc {
56984d9c625SLionel Sambuc 	const long double x = -0.0L;
57084d9c625SLionel Sambuc 	long double y = floorl(x);
57184d9c625SLionel Sambuc 
57284d9c625SLionel Sambuc 	if (fabsl(y) > 0.0 || signbit(y) == 0)
57384d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("floorl(-0.0) != -0.0");
57484d9c625SLionel Sambuc }
57584d9c625SLionel Sambuc 
57684d9c625SLionel Sambuc ATF_TC(floorl_zero_pos);
ATF_TC_HEAD(floorl_zero_pos,tc)57784d9c625SLionel Sambuc ATF_TC_HEAD(floorl_zero_pos, tc)
57884d9c625SLionel Sambuc {
57984d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test floorl(+0.0) == +0.0");
58084d9c625SLionel Sambuc }
58184d9c625SLionel Sambuc 
ATF_TC_BODY(floorl_zero_pos,tc)58284d9c625SLionel Sambuc ATF_TC_BODY(floorl_zero_pos, tc)
58384d9c625SLionel Sambuc {
58484d9c625SLionel Sambuc 	const long double x = 0.0L;
58584d9c625SLionel Sambuc 	long double y = floorl(x);
58684d9c625SLionel Sambuc 
58784d9c625SLionel Sambuc 	if (fabsl(y) > 0.0 || signbit(y) != 0)
58884d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("floorl(+0.0) != +0.0");
58984d9c625SLionel Sambuc }
59084d9c625SLionel Sambuc 
59184d9c625SLionel Sambuc /*
59284d9c625SLionel Sambuc  * trunc(3)
59384d9c625SLionel Sambuc  */
59484d9c625SLionel Sambuc ATF_TC(trunc_basic);
ATF_TC_HEAD(trunc_basic,tc)59584d9c625SLionel Sambuc ATF_TC_HEAD(trunc_basic, tc)
59684d9c625SLionel Sambuc {
59784d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "A basic test of trunc(3)");
59884d9c625SLionel Sambuc }
59984d9c625SLionel Sambuc 
ATF_TC_BODY(trunc_basic,tc)60084d9c625SLionel Sambuc ATF_TC_BODY(trunc_basic, tc)
60184d9c625SLionel Sambuc {
60284d9c625SLionel Sambuc 	const double x = 0.999999999999999;
60384d9c625SLionel Sambuc 	const double y = 0.000000000000001;
60484d9c625SLionel Sambuc 
60584d9c625SLionel Sambuc 	ATF_CHECK(trunc(x) < SMALL_NUM);
60684d9c625SLionel Sambuc 	ATF_CHECK(trunc(y) < SMALL_NUM);
60784d9c625SLionel Sambuc }
60884d9c625SLionel Sambuc 
60984d9c625SLionel Sambuc ATF_TC(trunc_nan);
ATF_TC_HEAD(trunc_nan,tc)61084d9c625SLionel Sambuc ATF_TC_HEAD(trunc_nan, tc)
61184d9c625SLionel Sambuc {
61284d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test trunc(NaN) == NaN");
61384d9c625SLionel Sambuc }
61484d9c625SLionel Sambuc 
ATF_TC_BODY(trunc_nan,tc)61584d9c625SLionel Sambuc ATF_TC_BODY(trunc_nan, tc)
61684d9c625SLionel Sambuc {
61784d9c625SLionel Sambuc 	const double x = 0.0L / 0.0L;
61884d9c625SLionel Sambuc 
61984d9c625SLionel Sambuc 	ATF_CHECK(isnan(trunc(x)) != 0);
62084d9c625SLionel Sambuc }
62184d9c625SLionel Sambuc 
62284d9c625SLionel Sambuc ATF_TC(trunc_inf_neg);
ATF_TC_HEAD(trunc_inf_neg,tc)62384d9c625SLionel Sambuc ATF_TC_HEAD(trunc_inf_neg, tc)
62484d9c625SLionel Sambuc {
62584d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test trunc(-Inf) == -Inf");
62684d9c625SLionel Sambuc }
62784d9c625SLionel Sambuc 
ATF_TC_BODY(trunc_inf_neg,tc)62884d9c625SLionel Sambuc ATF_TC_BODY(trunc_inf_neg, tc)
62984d9c625SLionel Sambuc {
63084d9c625SLionel Sambuc 	const double x = -1.0L / 0.0L;
63184d9c625SLionel Sambuc 	double y = trunc(x);
63284d9c625SLionel Sambuc 
63384d9c625SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) == 0)
63484d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("trunc(-Inf) != -Inf");
63584d9c625SLionel Sambuc }
63684d9c625SLionel Sambuc 
63784d9c625SLionel Sambuc ATF_TC(trunc_inf_pos);
ATF_TC_HEAD(trunc_inf_pos,tc)63884d9c625SLionel Sambuc ATF_TC_HEAD(trunc_inf_pos, tc)
63984d9c625SLionel Sambuc {
64084d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test trunc(+Inf) == +Inf");
64184d9c625SLionel Sambuc }
64284d9c625SLionel Sambuc 
ATF_TC_BODY(trunc_inf_pos,tc)64384d9c625SLionel Sambuc ATF_TC_BODY(trunc_inf_pos, tc)
64484d9c625SLionel Sambuc {
64584d9c625SLionel Sambuc 	const double x = 1.0L / 0.0L;
64684d9c625SLionel Sambuc 	double y = trunc(x);
64784d9c625SLionel Sambuc 
64884d9c625SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) != 0)
64984d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("trunc(+Inf) != +Inf");
65084d9c625SLionel Sambuc }
65184d9c625SLionel Sambuc 
65284d9c625SLionel Sambuc ATF_TC(trunc_zero_neg);
ATF_TC_HEAD(trunc_zero_neg,tc)65384d9c625SLionel Sambuc ATF_TC_HEAD(trunc_zero_neg, tc)
65484d9c625SLionel Sambuc {
65584d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test trunc(-0.0) == -0.0");
65684d9c625SLionel Sambuc }
65784d9c625SLionel Sambuc 
ATF_TC_BODY(trunc_zero_neg,tc)65884d9c625SLionel Sambuc ATF_TC_BODY(trunc_zero_neg, tc)
65984d9c625SLionel Sambuc {
66084d9c625SLionel Sambuc 	const double x = -0.0L;
66184d9c625SLionel Sambuc 	double y = trunc(x);
66284d9c625SLionel Sambuc 
66384d9c625SLionel Sambuc 	if (fabs(y) > 0.0 || signbit(y) == 0)
66484d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("trunc(-0.0) != -0.0");
66584d9c625SLionel Sambuc }
66684d9c625SLionel Sambuc 
66784d9c625SLionel Sambuc ATF_TC(trunc_zero_pos);
ATF_TC_HEAD(trunc_zero_pos,tc)66884d9c625SLionel Sambuc ATF_TC_HEAD(trunc_zero_pos, tc)
66984d9c625SLionel Sambuc {
67084d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test trunc(+0.0) == +0.0");
67184d9c625SLionel Sambuc }
67284d9c625SLionel Sambuc 
ATF_TC_BODY(trunc_zero_pos,tc)67384d9c625SLionel Sambuc ATF_TC_BODY(trunc_zero_pos, tc)
67484d9c625SLionel Sambuc {
67584d9c625SLionel Sambuc 	const double x = 0.0L;
67684d9c625SLionel Sambuc 	double y = trunc(x);
67784d9c625SLionel Sambuc 
67884d9c625SLionel Sambuc 	if (fabs(y) > 0.0 || signbit(y) != 0)
67984d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("trunc(+0.0) != +0.0");
68084d9c625SLionel Sambuc }
68184d9c625SLionel Sambuc 
68284d9c625SLionel Sambuc /*
68384d9c625SLionel Sambuc  * truncf(3)
68484d9c625SLionel Sambuc  */
68584d9c625SLionel Sambuc ATF_TC(truncf_basic);
ATF_TC_HEAD(truncf_basic,tc)68684d9c625SLionel Sambuc ATF_TC_HEAD(truncf_basic, tc)
68784d9c625SLionel Sambuc {
68884d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "A basic test of truncf(3)");
68984d9c625SLionel Sambuc }
69084d9c625SLionel Sambuc 
ATF_TC_BODY(truncf_basic,tc)69184d9c625SLionel Sambuc ATF_TC_BODY(truncf_basic, tc)
69284d9c625SLionel Sambuc {
69384d9c625SLionel Sambuc 	const float x = 0.9999999;
69484d9c625SLionel Sambuc 	const float y = 0.0000001;
69584d9c625SLionel Sambuc 
69684d9c625SLionel Sambuc 	ATF_CHECK(truncf(x) < SMALL_NUM);
69784d9c625SLionel Sambuc 	ATF_CHECK(truncf(y) < SMALL_NUM);
69884d9c625SLionel Sambuc }
69984d9c625SLionel Sambuc 
70084d9c625SLionel Sambuc ATF_TC(truncf_nan);
ATF_TC_HEAD(truncf_nan,tc)70184d9c625SLionel Sambuc ATF_TC_HEAD(truncf_nan, tc)
70284d9c625SLionel Sambuc {
70384d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test truncf(NaN) == NaN");
70484d9c625SLionel Sambuc }
70584d9c625SLionel Sambuc 
ATF_TC_BODY(truncf_nan,tc)70684d9c625SLionel Sambuc ATF_TC_BODY(truncf_nan, tc)
70784d9c625SLionel Sambuc {
70884d9c625SLionel Sambuc 	const float x = 0.0L / 0.0L;
70984d9c625SLionel Sambuc 
71084d9c625SLionel Sambuc 	ATF_CHECK(isnan(truncf(x)) != 0);
71184d9c625SLionel Sambuc }
71284d9c625SLionel Sambuc 
71384d9c625SLionel Sambuc ATF_TC(truncf_inf_neg);
ATF_TC_HEAD(truncf_inf_neg,tc)71484d9c625SLionel Sambuc ATF_TC_HEAD(truncf_inf_neg, tc)
71584d9c625SLionel Sambuc {
71684d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test truncf(-Inf) == -Inf");
71784d9c625SLionel Sambuc }
71884d9c625SLionel Sambuc 
ATF_TC_BODY(truncf_inf_neg,tc)71984d9c625SLionel Sambuc ATF_TC_BODY(truncf_inf_neg, tc)
72084d9c625SLionel Sambuc {
72184d9c625SLionel Sambuc 	const float x = -1.0L / 0.0L;
72284d9c625SLionel Sambuc 	float y = truncf(x);
72384d9c625SLionel Sambuc 
72484d9c625SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) == 0)
72584d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("truncf(-Inf) != -Inf");
72684d9c625SLionel Sambuc }
72784d9c625SLionel Sambuc 
72884d9c625SLionel Sambuc ATF_TC(truncf_inf_pos);
ATF_TC_HEAD(truncf_inf_pos,tc)72984d9c625SLionel Sambuc ATF_TC_HEAD(truncf_inf_pos, tc)
73084d9c625SLionel Sambuc {
73184d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test truncf(+Inf) == +Inf");
73284d9c625SLionel Sambuc }
73384d9c625SLionel Sambuc 
ATF_TC_BODY(truncf_inf_pos,tc)73484d9c625SLionel Sambuc ATF_TC_BODY(truncf_inf_pos, tc)
73584d9c625SLionel Sambuc {
73684d9c625SLionel Sambuc 	const float x = 1.0L / 0.0L;
73784d9c625SLionel Sambuc 	float y = truncf(x);
73884d9c625SLionel Sambuc 
73984d9c625SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) != 0)
74084d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("truncf(+Inf) != +Inf");
74184d9c625SLionel Sambuc }
74284d9c625SLionel Sambuc 
74384d9c625SLionel Sambuc ATF_TC(truncf_zero_neg);
ATF_TC_HEAD(truncf_zero_neg,tc)74484d9c625SLionel Sambuc ATF_TC_HEAD(truncf_zero_neg, tc)
74584d9c625SLionel Sambuc {
74684d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test truncf(-0.0) == -0.0");
74784d9c625SLionel Sambuc }
74884d9c625SLionel Sambuc 
ATF_TC_BODY(truncf_zero_neg,tc)74984d9c625SLionel Sambuc ATF_TC_BODY(truncf_zero_neg, tc)
75084d9c625SLionel Sambuc {
75184d9c625SLionel Sambuc 	const float x = -0.0L;
75284d9c625SLionel Sambuc 	float y = truncf(x);
75384d9c625SLionel Sambuc 
75484d9c625SLionel Sambuc 	if (fabsf(y) > 0.0 || signbit(y) == 0)
75584d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("truncf(-0.0) != -0.0");
75684d9c625SLionel Sambuc }
75784d9c625SLionel Sambuc 
75884d9c625SLionel Sambuc ATF_TC(truncf_zero_pos);
ATF_TC_HEAD(truncf_zero_pos,tc)75984d9c625SLionel Sambuc ATF_TC_HEAD(truncf_zero_pos, tc)
76084d9c625SLionel Sambuc {
76184d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test truncf(+0.0) == +0.0");
76284d9c625SLionel Sambuc }
76384d9c625SLionel Sambuc 
ATF_TC_BODY(truncf_zero_pos,tc)76484d9c625SLionel Sambuc ATF_TC_BODY(truncf_zero_pos, tc)
76584d9c625SLionel Sambuc {
76684d9c625SLionel Sambuc 	const float x = 0.0L;
76784d9c625SLionel Sambuc 	float y = truncf(x);
76884d9c625SLionel Sambuc 
76984d9c625SLionel Sambuc 	if (fabsf(y) > 0.0 || signbit(y) != 0)
77084d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("truncf(+0.0) != +0.0");
77184d9c625SLionel Sambuc }
77284d9c625SLionel Sambuc 
77384d9c625SLionel Sambuc /*
77484d9c625SLionel Sambuc  * truncl(3)
77584d9c625SLionel Sambuc  */
77684d9c625SLionel Sambuc ATF_TC(truncl_basic);
ATF_TC_HEAD(truncl_basic,tc)77784d9c625SLionel Sambuc ATF_TC_HEAD(truncl_basic, tc)
77884d9c625SLionel Sambuc {
77984d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "A basic test of truncl(3)");
78084d9c625SLionel Sambuc }
78184d9c625SLionel Sambuc 
ATF_TC_BODY(truncl_basic,tc)78284d9c625SLionel Sambuc ATF_TC_BODY(truncl_basic, tc)
78384d9c625SLionel Sambuc {
78484d9c625SLionel Sambuc 	const long double x = 0.9999999;
78584d9c625SLionel Sambuc 	const long double y = 0.0000001;
78684d9c625SLionel Sambuc 
78784d9c625SLionel Sambuc 	ATF_CHECK(truncl(x) < SMALL_NUM);
78884d9c625SLionel Sambuc 	ATF_CHECK(truncl(y) < SMALL_NUM);
78984d9c625SLionel Sambuc }
79084d9c625SLionel Sambuc 
79184d9c625SLionel Sambuc ATF_TC(truncl_nan);
ATF_TC_HEAD(truncl_nan,tc)79284d9c625SLionel Sambuc ATF_TC_HEAD(truncl_nan, tc)
79384d9c625SLionel Sambuc {
79484d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test truncl(NaN) == NaN");
79584d9c625SLionel Sambuc }
79684d9c625SLionel Sambuc 
ATF_TC_BODY(truncl_nan,tc)79784d9c625SLionel Sambuc ATF_TC_BODY(truncl_nan, tc)
79884d9c625SLionel Sambuc {
79984d9c625SLionel Sambuc 	const long double x = 0.0L / 0.0L;
80084d9c625SLionel Sambuc 
80184d9c625SLionel Sambuc 	ATF_CHECK(isnan(truncl(x)) != 0);
80284d9c625SLionel Sambuc }
80384d9c625SLionel Sambuc 
80484d9c625SLionel Sambuc ATF_TC(truncl_inf_neg);
ATF_TC_HEAD(truncl_inf_neg,tc)80584d9c625SLionel Sambuc ATF_TC_HEAD(truncl_inf_neg, tc)
80684d9c625SLionel Sambuc {
80784d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test truncl(-Inf) == -Inf");
80884d9c625SLionel Sambuc }
80984d9c625SLionel Sambuc 
ATF_TC_BODY(truncl_inf_neg,tc)81084d9c625SLionel Sambuc ATF_TC_BODY(truncl_inf_neg, tc)
81184d9c625SLionel Sambuc {
81284d9c625SLionel Sambuc 	const long double x = -1.0L / 0.0L;
81384d9c625SLionel Sambuc 	long double y = truncl(x);
81484d9c625SLionel Sambuc 
81584d9c625SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) == 0)
81684d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("truncl(-Inf) != -Inf");
81784d9c625SLionel Sambuc }
81884d9c625SLionel Sambuc 
81984d9c625SLionel Sambuc ATF_TC(truncl_inf_pos);
ATF_TC_HEAD(truncl_inf_pos,tc)82084d9c625SLionel Sambuc ATF_TC_HEAD(truncl_inf_pos, tc)
82184d9c625SLionel Sambuc {
82284d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test truncl(+Inf) == +Inf");
82384d9c625SLionel Sambuc }
82484d9c625SLionel Sambuc 
ATF_TC_BODY(truncl_inf_pos,tc)82584d9c625SLionel Sambuc ATF_TC_BODY(truncl_inf_pos, tc)
82684d9c625SLionel Sambuc {
82784d9c625SLionel Sambuc 	const long double x = 1.0L / 0.0L;
82884d9c625SLionel Sambuc 	long double y = truncl(x);
82984d9c625SLionel Sambuc 
83084d9c625SLionel Sambuc 	if (isinf(y) == 0 || signbit(y) != 0)
83184d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("truncl(+Inf) != +Inf");
83284d9c625SLionel Sambuc }
83384d9c625SLionel Sambuc 
83484d9c625SLionel Sambuc ATF_TC(truncl_zero_neg);
ATF_TC_HEAD(truncl_zero_neg,tc)83584d9c625SLionel Sambuc ATF_TC_HEAD(truncl_zero_neg, tc)
83684d9c625SLionel Sambuc {
83784d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test truncl(-0.0) == -0.0");
83884d9c625SLionel Sambuc }
83984d9c625SLionel Sambuc 
ATF_TC_BODY(truncl_zero_neg,tc)84084d9c625SLionel Sambuc ATF_TC_BODY(truncl_zero_neg, tc)
84184d9c625SLionel Sambuc {
84284d9c625SLionel Sambuc 	const long double x = -0.0L;
84384d9c625SLionel Sambuc 	long double y = truncl(x);
84484d9c625SLionel Sambuc 
84584d9c625SLionel Sambuc 	if (fabsl(y) > 0.0 || signbit(y) == 0)
84684d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("truncl(-0.0) != -0.0");
84784d9c625SLionel Sambuc }
84884d9c625SLionel Sambuc 
84984d9c625SLionel Sambuc ATF_TC(truncl_zero_pos);
ATF_TC_HEAD(truncl_zero_pos,tc)85084d9c625SLionel Sambuc ATF_TC_HEAD(truncl_zero_pos, tc)
85184d9c625SLionel Sambuc {
85284d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test truncl(+0.0) == +0.0");
85384d9c625SLionel Sambuc }
85484d9c625SLionel Sambuc 
ATF_TC_BODY(truncl_zero_pos,tc)85584d9c625SLionel Sambuc ATF_TC_BODY(truncl_zero_pos, tc)
85684d9c625SLionel Sambuc {
85784d9c625SLionel Sambuc 	const long double x = 0.0L;
85884d9c625SLionel Sambuc 	long double y = truncl(x);
85984d9c625SLionel Sambuc 
86084d9c625SLionel Sambuc 	if (fabsl(y) > 0.0 || signbit(y) != 0)
86184d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("truncl(+0.0) != +0.0");
86284d9c625SLionel Sambuc }
86384d9c625SLionel Sambuc 
ATF_TP_ADD_TCS(tp)86411be35a1SLionel Sambuc ATF_TP_ADD_TCS(tp)
86511be35a1SLionel Sambuc {
86611be35a1SLionel Sambuc 
86711be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceil_basic);
86811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceil_nan);
86911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceil_inf_neg);
87011be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceil_inf_pos);
87111be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceil_zero_neg);
87211be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceil_zero_pos);
87311be35a1SLionel Sambuc 
87411be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceilf_basic);
87511be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceilf_nan);
87611be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceilf_inf_neg);
87711be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceilf_inf_pos);
87811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceilf_zero_neg);
87911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceilf_zero_pos);
88011be35a1SLionel Sambuc 
88184d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceill_basic);
88284d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceill_nan);
88384d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceill_inf_neg);
88484d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceill_inf_pos);
88584d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceill_zero_neg);
88684d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, ceill_zero_pos);
88784d9c625SLionel Sambuc 
88811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floor_basic);
88911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floor_nan);
89011be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floor_inf_neg);
89111be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floor_inf_pos);
89211be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floor_zero_neg);
89311be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floor_zero_pos);
89411be35a1SLionel Sambuc 
89511be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorf_basic);
89611be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorf_nan);
89711be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorf_inf_neg);
89811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorf_inf_pos);
89911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorf_zero_neg);
90011be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorf_zero_pos);
90111be35a1SLionel Sambuc 
90284d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorl_basic);
90384d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorl_nan);
90484d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorl_inf_neg);
90584d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorl_inf_pos);
90684d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorl_zero_neg);
90784d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, floorl_zero_pos);
90884d9c625SLionel Sambuc 
90984d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, trunc_basic);
91084d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, trunc_nan);
91184d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, trunc_inf_neg);
91284d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, trunc_inf_pos);
91384d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, trunc_zero_neg);
91484d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, trunc_zero_pos);
91584d9c625SLionel Sambuc 
91684d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncf_basic);
91784d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncf_nan);
91884d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncf_inf_neg);
91984d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncf_inf_pos);
92084d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncf_zero_neg);
92184d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncf_zero_pos);
92284d9c625SLionel Sambuc 
92384d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncl_basic);
92484d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncl_nan);
92584d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncl_inf_neg);
92684d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncl_inf_pos);
92784d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncl_zero_neg);
92884d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, truncl_zero_pos);
92984d9c625SLionel Sambuc 
93011be35a1SLionel Sambuc 	return atf_no_error();
93111be35a1SLionel Sambuc }
932