xref: /minix3/tests/lib/libm/t_cbrt.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /* $NetBSD: t_cbrt.c,v 1.3 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_cbrt.c,v 1.3 2014/03/03 10:39:08 martin Exp $");
3311be35a1SLionel Sambuc 
3411be35a1SLionel Sambuc #include <atf-c.h>
3511be35a1SLionel Sambuc #include <math.h>
3611be35a1SLionel Sambuc #include <stdio.h>
3711be35a1SLionel Sambuc 
3811be35a1SLionel Sambuc /*
3911be35a1SLionel Sambuc  * cbrt(3)
4011be35a1SLionel Sambuc  */
4111be35a1SLionel Sambuc ATF_TC(cbrt_nan);
ATF_TC_HEAD(cbrt_nan,tc)4211be35a1SLionel Sambuc ATF_TC_HEAD(cbrt_nan, tc)
4311be35a1SLionel Sambuc {
4411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrt(NaN) == NaN");
4511be35a1SLionel Sambuc }
4611be35a1SLionel Sambuc 
ATF_TC_BODY(cbrt_nan,tc)4711be35a1SLionel Sambuc ATF_TC_BODY(cbrt_nan, tc)
4811be35a1SLionel Sambuc {
4911be35a1SLionel Sambuc 	const double x = 0.0L / 0.0L;
5011be35a1SLionel Sambuc 
5111be35a1SLionel Sambuc 	ATF_CHECK(isnan(x) != 0);
5211be35a1SLionel Sambuc 	ATF_CHECK(isnan(cbrt(x)) != 0);
5311be35a1SLionel Sambuc }
5411be35a1SLionel Sambuc 
5511be35a1SLionel Sambuc ATF_TC(cbrt_pow);
ATF_TC_HEAD(cbrt_pow,tc)5611be35a1SLionel Sambuc ATF_TC_HEAD(cbrt_pow, tc)
5711be35a1SLionel Sambuc {
5811be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrt(3) vs. pow(3)");
5911be35a1SLionel Sambuc }
6011be35a1SLionel Sambuc 
ATF_TC_BODY(cbrt_pow,tc)6111be35a1SLionel Sambuc ATF_TC_BODY(cbrt_pow, tc)
6211be35a1SLionel Sambuc {
6311be35a1SLionel Sambuc 	const double x[] = { 0.0, 0.005, 1.0, 99.0, 123.123, 9999.0 };
6411be35a1SLionel Sambuc 	const double eps = 1.0e-14;
6511be35a1SLionel Sambuc 	double y, z;
6611be35a1SLionel Sambuc 	size_t i;
6711be35a1SLionel Sambuc 
6811be35a1SLionel Sambuc 	for (i = 0; i < __arraycount(x); i++) {
6911be35a1SLionel Sambuc 
7011be35a1SLionel Sambuc 		y = cbrt(x[i]);
7111be35a1SLionel Sambuc 		z = pow(x[i], 1.0 / 3.0);
7211be35a1SLionel Sambuc 
7311be35a1SLionel Sambuc 		if (fabs(y - z) > eps)
7411be35a1SLionel Sambuc 			atf_tc_fail_nonfatal("cbrt(%0.03f) != "
7511be35a1SLionel Sambuc 			    "pow(%0.03f, 1/3)\n", x[i], x[i]);
7611be35a1SLionel Sambuc 	}
7711be35a1SLionel Sambuc }
7811be35a1SLionel Sambuc 
7911be35a1SLionel Sambuc ATF_TC(cbrt_inf_neg);
ATF_TC_HEAD(cbrt_inf_neg,tc)8011be35a1SLionel Sambuc ATF_TC_HEAD(cbrt_inf_neg, tc)
8111be35a1SLionel Sambuc {
8211be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrt(-Inf) == -Inf");
8311be35a1SLionel Sambuc }
8411be35a1SLionel Sambuc 
ATF_TC_BODY(cbrt_inf_neg,tc)8511be35a1SLionel Sambuc ATF_TC_BODY(cbrt_inf_neg, tc)
8611be35a1SLionel Sambuc {
8711be35a1SLionel Sambuc 	const double x = -1.0L / 0.0L;
8811be35a1SLionel Sambuc 	double y = cbrt(x);
8911be35a1SLionel Sambuc 
9011be35a1SLionel Sambuc 	ATF_CHECK(isinf(y) != 0);
9111be35a1SLionel Sambuc 	ATF_CHECK(signbit(y) != 0);
9211be35a1SLionel Sambuc }
9311be35a1SLionel Sambuc 
9411be35a1SLionel Sambuc ATF_TC(cbrt_inf_pos);
ATF_TC_HEAD(cbrt_inf_pos,tc)9511be35a1SLionel Sambuc ATF_TC_HEAD(cbrt_inf_pos, tc)
9611be35a1SLionel Sambuc {
9711be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrt(+Inf) == +Inf");
9811be35a1SLionel Sambuc }
9911be35a1SLionel Sambuc 
ATF_TC_BODY(cbrt_inf_pos,tc)10011be35a1SLionel Sambuc ATF_TC_BODY(cbrt_inf_pos, tc)
10111be35a1SLionel Sambuc {
10211be35a1SLionel Sambuc 	const double x = 1.0L / 0.0L;
10311be35a1SLionel Sambuc 	double y = cbrt(x);
10411be35a1SLionel Sambuc 
10511be35a1SLionel Sambuc 	ATF_CHECK(isinf(y) != 0);
10611be35a1SLionel Sambuc 	ATF_CHECK(signbit(y) == 0);
10711be35a1SLionel Sambuc }
10811be35a1SLionel Sambuc 
10911be35a1SLionel Sambuc ATF_TC(cbrt_zero_neg);
ATF_TC_HEAD(cbrt_zero_neg,tc)11011be35a1SLionel Sambuc ATF_TC_HEAD(cbrt_zero_neg, tc)
11111be35a1SLionel Sambuc {
11211be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrt(-0.0) == -0.0");
11311be35a1SLionel Sambuc }
11411be35a1SLionel Sambuc 
ATF_TC_BODY(cbrt_zero_neg,tc)11511be35a1SLionel Sambuc ATF_TC_BODY(cbrt_zero_neg, tc)
11611be35a1SLionel Sambuc {
11711be35a1SLionel Sambuc 	const double x = -0.0L;
11811be35a1SLionel Sambuc 	double y = cbrt(x);
11911be35a1SLionel Sambuc 
12011be35a1SLionel Sambuc 	if (fabs(y) > 0.0 || signbit(y) == 0)
12111be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("cbrt(-0.0) != -0.0");
12211be35a1SLionel Sambuc }
12311be35a1SLionel Sambuc 
12411be35a1SLionel Sambuc ATF_TC(cbrt_zero_pos);
ATF_TC_HEAD(cbrt_zero_pos,tc)12511be35a1SLionel Sambuc ATF_TC_HEAD(cbrt_zero_pos, tc)
12611be35a1SLionel Sambuc {
12711be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrt(+0.0) == +0.0");
12811be35a1SLionel Sambuc }
12911be35a1SLionel Sambuc 
ATF_TC_BODY(cbrt_zero_pos,tc)13011be35a1SLionel Sambuc ATF_TC_BODY(cbrt_zero_pos, tc)
13111be35a1SLionel Sambuc {
13211be35a1SLionel Sambuc 	const double x = 0.0L;
13311be35a1SLionel Sambuc 	double y = cbrt(x);
13411be35a1SLionel Sambuc 
13511be35a1SLionel Sambuc 	if (fabs(y) > 0.0 || signbit(y) != 0)
13611be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("cbrt(+0.0) != +0.0");
13711be35a1SLionel Sambuc }
13811be35a1SLionel Sambuc 
13911be35a1SLionel Sambuc /*
14011be35a1SLionel Sambuc  * cbrtf(3)
14111be35a1SLionel Sambuc  */
14211be35a1SLionel Sambuc ATF_TC(cbrtf_nan);
ATF_TC_HEAD(cbrtf_nan,tc)14311be35a1SLionel Sambuc ATF_TC_HEAD(cbrtf_nan, tc)
14411be35a1SLionel Sambuc {
14511be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtf(NaN) == NaN");
14611be35a1SLionel Sambuc }
14711be35a1SLionel Sambuc 
ATF_TC_BODY(cbrtf_nan,tc)14811be35a1SLionel Sambuc ATF_TC_BODY(cbrtf_nan, tc)
14911be35a1SLionel Sambuc {
15011be35a1SLionel Sambuc 	const float x = 0.0L / 0.0L;
15111be35a1SLionel Sambuc 
15211be35a1SLionel Sambuc 	ATF_CHECK(isnan(x) != 0);
15311be35a1SLionel Sambuc 	ATF_CHECK(isnan(cbrtf(x)) != 0);
15411be35a1SLionel Sambuc }
15511be35a1SLionel Sambuc 
15611be35a1SLionel Sambuc ATF_TC(cbrtf_powf);
ATF_TC_HEAD(cbrtf_powf,tc)15711be35a1SLionel Sambuc ATF_TC_HEAD(cbrtf_powf, tc)
15811be35a1SLionel Sambuc {
15911be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtf(3) vs. powf(3)");
16011be35a1SLionel Sambuc }
16111be35a1SLionel Sambuc 
ATF_TC_BODY(cbrtf_powf,tc)16211be35a1SLionel Sambuc ATF_TC_BODY(cbrtf_powf, tc)
16311be35a1SLionel Sambuc {
16411be35a1SLionel Sambuc 	const float x[] = { 0.0, 0.005, 1.0, 99.0, 123.123, 9999.0 };
16511be35a1SLionel Sambuc 	const float eps = 1.0e-5;
16611be35a1SLionel Sambuc 	float y, z;
16711be35a1SLionel Sambuc 	size_t i;
16811be35a1SLionel Sambuc 
16911be35a1SLionel Sambuc 	for (i = 0; i < __arraycount(x); i++) {
17011be35a1SLionel Sambuc 
17111be35a1SLionel Sambuc 		y = cbrtf(x[i]);
17211be35a1SLionel Sambuc 		z = powf(x[i], 1.0 / 3.0);
17311be35a1SLionel Sambuc 
17411be35a1SLionel Sambuc 		if (fabsf(y - z) > eps)
17511be35a1SLionel Sambuc 			atf_tc_fail_nonfatal("cbrtf(%0.03f) != "
17611be35a1SLionel Sambuc 			    "powf(%0.03f, 1/3)\n", x[i], x[i]);
17711be35a1SLionel Sambuc 	}
17811be35a1SLionel Sambuc }
17911be35a1SLionel Sambuc 
18011be35a1SLionel Sambuc ATF_TC(cbrtf_inf_neg);
ATF_TC_HEAD(cbrtf_inf_neg,tc)18111be35a1SLionel Sambuc ATF_TC_HEAD(cbrtf_inf_neg, tc)
18211be35a1SLionel Sambuc {
18311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtf(-Inf) == -Inf");
18411be35a1SLionel Sambuc }
18511be35a1SLionel Sambuc 
ATF_TC_BODY(cbrtf_inf_neg,tc)18611be35a1SLionel Sambuc ATF_TC_BODY(cbrtf_inf_neg, tc)
18711be35a1SLionel Sambuc {
18811be35a1SLionel Sambuc 	const float x = -1.0L / 0.0L;
18911be35a1SLionel Sambuc 	float y = cbrtf(x);
19011be35a1SLionel Sambuc 
19111be35a1SLionel Sambuc 	ATF_CHECK(isinf(y) != 0);
19211be35a1SLionel Sambuc 	ATF_CHECK(signbit(y) != 0);
19311be35a1SLionel Sambuc }
19411be35a1SLionel Sambuc 
19511be35a1SLionel Sambuc ATF_TC(cbrtf_inf_pos);
ATF_TC_HEAD(cbrtf_inf_pos,tc)19611be35a1SLionel Sambuc ATF_TC_HEAD(cbrtf_inf_pos, tc)
19711be35a1SLionel Sambuc {
19811be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtf(+Inf) == +Inf");
19911be35a1SLionel Sambuc }
20011be35a1SLionel Sambuc 
ATF_TC_BODY(cbrtf_inf_pos,tc)20111be35a1SLionel Sambuc ATF_TC_BODY(cbrtf_inf_pos, tc)
20211be35a1SLionel Sambuc {
20311be35a1SLionel Sambuc 	const float x = 1.0L / 0.0L;
20411be35a1SLionel Sambuc 	float y = cbrtf(x);
20511be35a1SLionel Sambuc 
20611be35a1SLionel Sambuc 	ATF_CHECK(isinf(y) != 0);
20711be35a1SLionel Sambuc 	ATF_CHECK(signbit(y) == 0);
20811be35a1SLionel Sambuc }
20911be35a1SLionel Sambuc 
21011be35a1SLionel Sambuc ATF_TC(cbrtf_zero_neg);
ATF_TC_HEAD(cbrtf_zero_neg,tc)21111be35a1SLionel Sambuc ATF_TC_HEAD(cbrtf_zero_neg, tc)
21211be35a1SLionel Sambuc {
21311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtf(-0.0) == -0.0");
21411be35a1SLionel Sambuc }
21511be35a1SLionel Sambuc 
ATF_TC_BODY(cbrtf_zero_neg,tc)21611be35a1SLionel Sambuc ATF_TC_BODY(cbrtf_zero_neg, tc)
21711be35a1SLionel Sambuc {
21811be35a1SLionel Sambuc 	const float x = -0.0L;
21911be35a1SLionel Sambuc 	float y = cbrtf(x);
22011be35a1SLionel Sambuc 
22111be35a1SLionel Sambuc 	if (fabsf(y) > 0.0 || signbit(y) == 0)
22211be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("cbrtf(-0.0) != -0.0");
22311be35a1SLionel Sambuc }
22411be35a1SLionel Sambuc 
22511be35a1SLionel Sambuc ATF_TC(cbrtf_zero_pos);
ATF_TC_HEAD(cbrtf_zero_pos,tc)22611be35a1SLionel Sambuc ATF_TC_HEAD(cbrtf_zero_pos, tc)
22711be35a1SLionel Sambuc {
22811be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtf(+0.0) == +0.0");
22911be35a1SLionel Sambuc }
23011be35a1SLionel Sambuc 
ATF_TC_BODY(cbrtf_zero_pos,tc)23111be35a1SLionel Sambuc ATF_TC_BODY(cbrtf_zero_pos, tc)
23211be35a1SLionel Sambuc {
23311be35a1SLionel Sambuc 	const float x = 0.0L;
23411be35a1SLionel Sambuc 	float y = cbrtf(x);
23511be35a1SLionel Sambuc 
23611be35a1SLionel Sambuc 	if (fabsf(y) > 0.0 || signbit(y) != 0)
23711be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("cbrtf(+0.0) != +0.0");
23811be35a1SLionel Sambuc }
23911be35a1SLionel Sambuc 
24084d9c625SLionel Sambuc /*
24184d9c625SLionel Sambuc  * cbrtl(3)
24284d9c625SLionel Sambuc  */
24384d9c625SLionel Sambuc ATF_TC(cbrtl_nan);
ATF_TC_HEAD(cbrtl_nan,tc)24484d9c625SLionel Sambuc ATF_TC_HEAD(cbrtl_nan, tc)
24584d9c625SLionel Sambuc {
24684d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtl(NaN) == NaN");
24784d9c625SLionel Sambuc }
24884d9c625SLionel Sambuc 
ATF_TC_BODY(cbrtl_nan,tc)24984d9c625SLionel Sambuc ATF_TC_BODY(cbrtl_nan, tc)
25084d9c625SLionel Sambuc {
25184d9c625SLionel Sambuc 	const long double x = 0.0L / 0.0L;
25284d9c625SLionel Sambuc 
25384d9c625SLionel Sambuc 	ATF_CHECK(isnan(x) != 0);
25484d9c625SLionel Sambuc 	ATF_CHECK(isnan(cbrtl(x)) != 0);
25584d9c625SLionel Sambuc }
25684d9c625SLionel Sambuc 
25784d9c625SLionel Sambuc ATF_TC(cbrtl_powl);
ATF_TC_HEAD(cbrtl_powl,tc)25884d9c625SLionel Sambuc ATF_TC_HEAD(cbrtl_powl, tc)
25984d9c625SLionel Sambuc {
26084d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtl(3) vs. powl(3)");
26184d9c625SLionel Sambuc }
26284d9c625SLionel Sambuc 
ATF_TC_BODY(cbrtl_powl,tc)26384d9c625SLionel Sambuc ATF_TC_BODY(cbrtl_powl, tc)
26484d9c625SLionel Sambuc {
26584d9c625SLionel Sambuc 	const long double x[] = { 0.0, 0.005, 1.0, 99.0, 123.123, 9999.0 };
26684d9c625SLionel Sambuc 	const long double eps = 1.0e-15;
26784d9c625SLionel Sambuc 	long double y, z;
26884d9c625SLionel Sambuc 	size_t i;
26984d9c625SLionel Sambuc 
27084d9c625SLionel Sambuc 	for (i = 0; i < __arraycount(x); i++) {
27184d9c625SLionel Sambuc 
27284d9c625SLionel Sambuc 		y = cbrtl(x[i]);
27384d9c625SLionel Sambuc 		z = powl(x[i], 1.0 / 3.0);
27484d9c625SLionel Sambuc 
27584d9c625SLionel Sambuc 		if (fabsl(y - z) > eps * fabsl(1 + x[i]))
27684d9c625SLionel Sambuc 			atf_tc_fail_nonfatal("cbrtl(%0.03Lf) != "
27784d9c625SLionel Sambuc 			    "powl(%0.03Lf, 1/3)\n", x[i], x[i]);
27884d9c625SLionel Sambuc 	}
27984d9c625SLionel Sambuc }
28084d9c625SLionel Sambuc 
28184d9c625SLionel Sambuc ATF_TC(cbrtl_inf_neg);
ATF_TC_HEAD(cbrtl_inf_neg,tc)28284d9c625SLionel Sambuc ATF_TC_HEAD(cbrtl_inf_neg, tc)
28384d9c625SLionel Sambuc {
28484d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtl(-Inf) == -Inf");
28584d9c625SLionel Sambuc }
28684d9c625SLionel Sambuc 
ATF_TC_BODY(cbrtl_inf_neg,tc)28784d9c625SLionel Sambuc ATF_TC_BODY(cbrtl_inf_neg, tc)
28884d9c625SLionel Sambuc {
28984d9c625SLionel Sambuc 	const long double x = -1.0L / 0.0L;
29084d9c625SLionel Sambuc 	long double y = cbrtl(x);
29184d9c625SLionel Sambuc 
29284d9c625SLionel Sambuc 	ATF_CHECK(isinf(y) != 0);
29384d9c625SLionel Sambuc 	ATF_CHECK(signbit(y) != 0);
29484d9c625SLionel Sambuc }
29584d9c625SLionel Sambuc 
29684d9c625SLionel Sambuc ATF_TC(cbrtl_inf_pos);
ATF_TC_HEAD(cbrtl_inf_pos,tc)29784d9c625SLionel Sambuc ATF_TC_HEAD(cbrtl_inf_pos, tc)
29884d9c625SLionel Sambuc {
29984d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtl(+Inf) == +Inf");
30084d9c625SLionel Sambuc }
30184d9c625SLionel Sambuc 
ATF_TC_BODY(cbrtl_inf_pos,tc)30284d9c625SLionel Sambuc ATF_TC_BODY(cbrtl_inf_pos, tc)
30384d9c625SLionel Sambuc {
30484d9c625SLionel Sambuc 	const long double x = 1.0L / 0.0L;
30584d9c625SLionel Sambuc 	long double y = cbrtl(x);
30684d9c625SLionel Sambuc 
30784d9c625SLionel Sambuc 	ATF_CHECK(isinf(y) != 0);
30884d9c625SLionel Sambuc 	ATF_CHECK(signbit(y) == 0);
30984d9c625SLionel Sambuc }
31084d9c625SLionel Sambuc 
31184d9c625SLionel Sambuc ATF_TC(cbrtl_zero_neg);
ATF_TC_HEAD(cbrtl_zero_neg,tc)31284d9c625SLionel Sambuc ATF_TC_HEAD(cbrtl_zero_neg, tc)
31384d9c625SLionel Sambuc {
31484d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtl(-0.0) == -0.0");
31584d9c625SLionel Sambuc }
31684d9c625SLionel Sambuc 
ATF_TC_BODY(cbrtl_zero_neg,tc)31784d9c625SLionel Sambuc ATF_TC_BODY(cbrtl_zero_neg, tc)
31884d9c625SLionel Sambuc {
31984d9c625SLionel Sambuc 	const long double x = -0.0L;
32084d9c625SLionel Sambuc 	long double y = cbrtl(x);
32184d9c625SLionel Sambuc 
32284d9c625SLionel Sambuc 	if (fabsl(y) > 0.0 || signbit(y) == 0)
32384d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("cbrtl(-0.0) != -0.0");
32484d9c625SLionel Sambuc }
32584d9c625SLionel Sambuc 
32684d9c625SLionel Sambuc ATF_TC(cbrtl_zero_pos);
ATF_TC_HEAD(cbrtl_zero_pos,tc)32784d9c625SLionel Sambuc ATF_TC_HEAD(cbrtl_zero_pos, tc)
32884d9c625SLionel Sambuc {
32984d9c625SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test cbrtl(+0.0) == +0.0");
33084d9c625SLionel Sambuc }
33184d9c625SLionel Sambuc 
ATF_TC_BODY(cbrtl_zero_pos,tc)33284d9c625SLionel Sambuc ATF_TC_BODY(cbrtl_zero_pos, tc)
33384d9c625SLionel Sambuc {
33484d9c625SLionel Sambuc 	const long double x = 0.0L;
33584d9c625SLionel Sambuc 	long double y = cbrtl(x);
33684d9c625SLionel Sambuc 
33784d9c625SLionel Sambuc 	if (fabsl(y) > 0.0 || signbit(y) != 0)
33884d9c625SLionel Sambuc 		atf_tc_fail_nonfatal("cbrtl(+0.0) != +0.0");
33984d9c625SLionel Sambuc }
34084d9c625SLionel Sambuc 
ATF_TP_ADD_TCS(tp)34111be35a1SLionel Sambuc ATF_TP_ADD_TCS(tp)
34211be35a1SLionel Sambuc {
34311be35a1SLionel Sambuc 
34411be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrt_nan);
34511be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrt_pow);
34611be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrt_inf_neg);
34711be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrt_inf_pos);
34811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrt_zero_neg);
34911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrt_zero_pos);
35011be35a1SLionel Sambuc 
35111be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtf_nan);
35211be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtf_powf);
35311be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtf_inf_neg);
35411be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtf_inf_pos);
35511be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtf_zero_neg);
35611be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtf_zero_pos);
35711be35a1SLionel Sambuc 
35884d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtl_nan);
35984d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtl_powl);
36084d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtl_inf_neg);
36184d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtl_inf_pos);
36284d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtl_zero_neg);
36384d9c625SLionel Sambuc 	ATF_TP_ADD_TC(tp, cbrtl_zero_pos);
36484d9c625SLionel Sambuc 
36511be35a1SLionel Sambuc 	return atf_no_error();
36611be35a1SLionel Sambuc }
367