xref: /minix3/tests/lib/libm/t_log.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /* $NetBSD: t_log.c,v 1.13 2015/02/09 19:39:48 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_log.c,v 1.13 2015/02/09 19:39:48 martin Exp $");
3311be35a1SLionel Sambuc 
3411be35a1SLionel Sambuc #include <atf-c.h>
3511be35a1SLionel Sambuc 
3611be35a1SLionel Sambuc #include <math.h>
3711be35a1SLionel Sambuc #include <stdio.h>
3811be35a1SLionel Sambuc #include <string.h>
3911be35a1SLionel Sambuc 
4011be35a1SLionel Sambuc /*
4111be35a1SLionel Sambuc  * log10(3)
4211be35a1SLionel Sambuc  */
4311be35a1SLionel Sambuc ATF_TC(log10_base);
ATF_TC_HEAD(log10_base,tc)4411be35a1SLionel Sambuc ATF_TC_HEAD(log10_base, tc)
4511be35a1SLionel Sambuc {
4611be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10(10) == 1");
4711be35a1SLionel Sambuc }
4811be35a1SLionel Sambuc 
ATF_TC_BODY(log10_base,tc)4911be35a1SLionel Sambuc ATF_TC_BODY(log10_base, tc)
5011be35a1SLionel Sambuc {
5111be35a1SLionel Sambuc 	ATF_CHECK(log10(10.0) == 1.0);
5211be35a1SLionel Sambuc }
5311be35a1SLionel Sambuc 
5411be35a1SLionel Sambuc ATF_TC(log10_nan);
ATF_TC_HEAD(log10_nan,tc)5511be35a1SLionel Sambuc ATF_TC_HEAD(log10_nan, tc)
5611be35a1SLionel Sambuc {
5711be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10(NaN) == NaN");
5811be35a1SLionel Sambuc }
5911be35a1SLionel Sambuc 
ATF_TC_BODY(log10_nan,tc)6011be35a1SLionel Sambuc ATF_TC_BODY(log10_nan, tc)
6111be35a1SLionel Sambuc {
6211be35a1SLionel Sambuc 	const double x = 0.0L / 0.0L;
6311be35a1SLionel Sambuc 
6411be35a1SLionel Sambuc 	ATF_CHECK(isnan(x) != 0);
6511be35a1SLionel Sambuc 	ATF_CHECK(isnan(log10(x)) != 0);
6611be35a1SLionel Sambuc }
6711be35a1SLionel Sambuc 
6811be35a1SLionel Sambuc ATF_TC(log10_inf_neg);
ATF_TC_HEAD(log10_inf_neg,tc)6911be35a1SLionel Sambuc ATF_TC_HEAD(log10_inf_neg, tc)
7011be35a1SLionel Sambuc {
7111be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10(-Inf) == NaN");
7211be35a1SLionel Sambuc }
7311be35a1SLionel Sambuc 
ATF_TC_BODY(log10_inf_neg,tc)7411be35a1SLionel Sambuc ATF_TC_BODY(log10_inf_neg, tc)
7511be35a1SLionel Sambuc {
7611be35a1SLionel Sambuc 	const double x = -1.0L / 0.0L;
7711be35a1SLionel Sambuc 	const double y = log10(x);
7811be35a1SLionel Sambuc 
7911be35a1SLionel Sambuc 	ATF_CHECK(isnan(y) != 0);
8011be35a1SLionel Sambuc }
8111be35a1SLionel Sambuc 
8211be35a1SLionel Sambuc ATF_TC(log10_inf_pos);
ATF_TC_HEAD(log10_inf_pos,tc)8311be35a1SLionel Sambuc ATF_TC_HEAD(log10_inf_pos, tc)
8411be35a1SLionel Sambuc {
8511be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10(+Inf) == +Inf");
8611be35a1SLionel Sambuc }
8711be35a1SLionel Sambuc 
ATF_TC_BODY(log10_inf_pos,tc)8811be35a1SLionel Sambuc ATF_TC_BODY(log10_inf_pos, tc)
8911be35a1SLionel Sambuc {
9011be35a1SLionel Sambuc 	const double x = 1.0L / 0.0L;
9111be35a1SLionel Sambuc 
9211be35a1SLionel Sambuc 	ATF_CHECK(log10(x) == x);
9311be35a1SLionel Sambuc }
9411be35a1SLionel Sambuc 
9511be35a1SLionel Sambuc ATF_TC(log10_one_pos);
ATF_TC_HEAD(log10_one_pos,tc)9611be35a1SLionel Sambuc ATF_TC_HEAD(log10_one_pos, tc)
9711be35a1SLionel Sambuc {
9811be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10(1.0) == +0.0");
9911be35a1SLionel Sambuc }
10011be35a1SLionel Sambuc 
ATF_TC_BODY(log10_one_pos,tc)10111be35a1SLionel Sambuc ATF_TC_BODY(log10_one_pos, tc)
10211be35a1SLionel Sambuc {
10311be35a1SLionel Sambuc 	const double x = log10(1.0);
10411be35a1SLionel Sambuc 	const double y = 0.0L;
10511be35a1SLionel Sambuc 
10611be35a1SLionel Sambuc 	ATF_CHECK(x == y);
10711be35a1SLionel Sambuc 	ATF_CHECK(signbit(x) == 0);
10811be35a1SLionel Sambuc 	ATF_CHECK(signbit(y) == 0);
10911be35a1SLionel Sambuc }
11011be35a1SLionel Sambuc 
11111be35a1SLionel Sambuc ATF_TC(log10_zero_neg);
ATF_TC_HEAD(log10_zero_neg,tc)11211be35a1SLionel Sambuc ATF_TC_HEAD(log10_zero_neg, tc)
11311be35a1SLionel Sambuc {
11411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10(-0.0) == -HUGE_VAL");
11511be35a1SLionel Sambuc }
11611be35a1SLionel Sambuc 
ATF_TC_BODY(log10_zero_neg,tc)11711be35a1SLionel Sambuc ATF_TC_BODY(log10_zero_neg, tc)
11811be35a1SLionel Sambuc {
11911be35a1SLionel Sambuc 	const double x = -0.0L;
12011be35a1SLionel Sambuc 
12111be35a1SLionel Sambuc 	ATF_CHECK(log10(x) == -HUGE_VAL);
12211be35a1SLionel Sambuc }
12311be35a1SLionel Sambuc 
12411be35a1SLionel Sambuc ATF_TC(log10_zero_pos);
ATF_TC_HEAD(log10_zero_pos,tc)12511be35a1SLionel Sambuc ATF_TC_HEAD(log10_zero_pos, tc)
12611be35a1SLionel Sambuc {
12711be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10(+0.0) == -HUGE_VAL");
12811be35a1SLionel Sambuc }
12911be35a1SLionel Sambuc 
ATF_TC_BODY(log10_zero_pos,tc)13011be35a1SLionel Sambuc ATF_TC_BODY(log10_zero_pos, tc)
13111be35a1SLionel Sambuc {
13211be35a1SLionel Sambuc 	const double x = 0.0L;
13311be35a1SLionel Sambuc 
13411be35a1SLionel Sambuc 	ATF_CHECK(log10(x) == -HUGE_VAL);
13511be35a1SLionel Sambuc }
13611be35a1SLionel Sambuc 
13711be35a1SLionel Sambuc /*
13811be35a1SLionel Sambuc  * log10f(3)
13911be35a1SLionel Sambuc  */
14011be35a1SLionel Sambuc ATF_TC(log10f_base);
ATF_TC_HEAD(log10f_base,tc)14111be35a1SLionel Sambuc ATF_TC_HEAD(log10f_base, tc)
14211be35a1SLionel Sambuc {
14311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10f(10) == 1");
14411be35a1SLionel Sambuc }
14511be35a1SLionel Sambuc 
ATF_TC_BODY(log10f_base,tc)14611be35a1SLionel Sambuc ATF_TC_BODY(log10f_base, tc)
14711be35a1SLionel Sambuc {
14811be35a1SLionel Sambuc 	ATF_CHECK(log10f(10.0) == 1.0);
14911be35a1SLionel Sambuc }
15011be35a1SLionel Sambuc 
15111be35a1SLionel Sambuc ATF_TC(log10f_nan);
ATF_TC_HEAD(log10f_nan,tc)15211be35a1SLionel Sambuc ATF_TC_HEAD(log10f_nan, tc)
15311be35a1SLionel Sambuc {
15411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10f(NaN) == NaN");
15511be35a1SLionel Sambuc }
15611be35a1SLionel Sambuc 
ATF_TC_BODY(log10f_nan,tc)15711be35a1SLionel Sambuc ATF_TC_BODY(log10f_nan, tc)
15811be35a1SLionel Sambuc {
15911be35a1SLionel Sambuc 	const float x = 0.0L / 0.0L;
16011be35a1SLionel Sambuc 
16111be35a1SLionel Sambuc 	ATF_CHECK(isnan(x) != 0);
16211be35a1SLionel Sambuc 	ATF_CHECK(isnan(log10f(x)) != 0);
16311be35a1SLionel Sambuc }
16411be35a1SLionel Sambuc 
16511be35a1SLionel Sambuc ATF_TC(log10f_inf_neg);
ATF_TC_HEAD(log10f_inf_neg,tc)16611be35a1SLionel Sambuc ATF_TC_HEAD(log10f_inf_neg, tc)
16711be35a1SLionel Sambuc {
16811be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10f(-Inf) == NaN");
16911be35a1SLionel Sambuc }
17011be35a1SLionel Sambuc 
ATF_TC_BODY(log10f_inf_neg,tc)17111be35a1SLionel Sambuc ATF_TC_BODY(log10f_inf_neg, tc)
17211be35a1SLionel Sambuc {
17311be35a1SLionel Sambuc 	const float x = -1.0L / 0.0L;
17411be35a1SLionel Sambuc 	const float y = log10f(x);
17511be35a1SLionel Sambuc 
17611be35a1SLionel Sambuc 	ATF_CHECK(isnan(y) != 0);
17711be35a1SLionel Sambuc }
17811be35a1SLionel Sambuc 
17911be35a1SLionel Sambuc ATF_TC(log10f_inf_pos);
ATF_TC_HEAD(log10f_inf_pos,tc)18011be35a1SLionel Sambuc ATF_TC_HEAD(log10f_inf_pos, tc)
18111be35a1SLionel Sambuc {
18211be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10f(+Inf) == +Inf");
18311be35a1SLionel Sambuc }
18411be35a1SLionel Sambuc 
ATF_TC_BODY(log10f_inf_pos,tc)18511be35a1SLionel Sambuc ATF_TC_BODY(log10f_inf_pos, tc)
18611be35a1SLionel Sambuc {
18711be35a1SLionel Sambuc 	const float x = 1.0L / 0.0L;
18811be35a1SLionel Sambuc 
18911be35a1SLionel Sambuc 	ATF_CHECK(log10f(x) == x);
19011be35a1SLionel Sambuc }
19111be35a1SLionel Sambuc 
19211be35a1SLionel Sambuc ATF_TC(log10f_one_pos);
ATF_TC_HEAD(log10f_one_pos,tc)19311be35a1SLionel Sambuc ATF_TC_HEAD(log10f_one_pos, tc)
19411be35a1SLionel Sambuc {
19511be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10f(1.0) == +0.0");
19611be35a1SLionel Sambuc }
19711be35a1SLionel Sambuc 
ATF_TC_BODY(log10f_one_pos,tc)19811be35a1SLionel Sambuc ATF_TC_BODY(log10f_one_pos, tc)
19911be35a1SLionel Sambuc {
20011be35a1SLionel Sambuc 	const float x = log10f(1.0);
20111be35a1SLionel Sambuc 	const float y = 0.0L;
20211be35a1SLionel Sambuc 
20311be35a1SLionel Sambuc 	ATF_CHECK(x == y);
20411be35a1SLionel Sambuc 	ATF_CHECK(signbit(x) == 0);
20511be35a1SLionel Sambuc 	ATF_CHECK(signbit(y) == 0);
20611be35a1SLionel Sambuc }
20711be35a1SLionel Sambuc 
20811be35a1SLionel Sambuc ATF_TC(log10f_zero_neg);
ATF_TC_HEAD(log10f_zero_neg,tc)20911be35a1SLionel Sambuc ATF_TC_HEAD(log10f_zero_neg, tc)
21011be35a1SLionel Sambuc {
21111be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10f(-0.0) == -HUGE_VALF");
21211be35a1SLionel Sambuc }
21311be35a1SLionel Sambuc 
ATF_TC_BODY(log10f_zero_neg,tc)21411be35a1SLionel Sambuc ATF_TC_BODY(log10f_zero_neg, tc)
21511be35a1SLionel Sambuc {
21611be35a1SLionel Sambuc 	const float x = -0.0L;
21711be35a1SLionel Sambuc 
21811be35a1SLionel Sambuc 	ATF_CHECK(log10f(x) == -HUGE_VALF);
21911be35a1SLionel Sambuc }
22011be35a1SLionel Sambuc 
22111be35a1SLionel Sambuc ATF_TC(log10f_zero_pos);
ATF_TC_HEAD(log10f_zero_pos,tc)22211be35a1SLionel Sambuc ATF_TC_HEAD(log10f_zero_pos, tc)
22311be35a1SLionel Sambuc {
22411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log10f(+0.0) == -HUGE_VALF");
22511be35a1SLionel Sambuc }
22611be35a1SLionel Sambuc 
ATF_TC_BODY(log10f_zero_pos,tc)22711be35a1SLionel Sambuc ATF_TC_BODY(log10f_zero_pos, tc)
22811be35a1SLionel Sambuc {
22911be35a1SLionel Sambuc 	const float x = 0.0L;
23011be35a1SLionel Sambuc 
23111be35a1SLionel Sambuc 	ATF_CHECK(log10f(x) == -HUGE_VALF);
23211be35a1SLionel Sambuc }
23311be35a1SLionel Sambuc 
23411be35a1SLionel Sambuc /*
23511be35a1SLionel Sambuc  * log1p(3)
23611be35a1SLionel Sambuc  */
23711be35a1SLionel Sambuc ATF_TC(log1p_nan);
ATF_TC_HEAD(log1p_nan,tc)23811be35a1SLionel Sambuc ATF_TC_HEAD(log1p_nan, tc)
23911be35a1SLionel Sambuc {
24011be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1p(NaN) == NaN");
24111be35a1SLionel Sambuc }
24211be35a1SLionel Sambuc 
ATF_TC_BODY(log1p_nan,tc)24311be35a1SLionel Sambuc ATF_TC_BODY(log1p_nan, tc)
24411be35a1SLionel Sambuc {
24511be35a1SLionel Sambuc 	const double x = 0.0L / 0.0L;
24611be35a1SLionel Sambuc 
24711be35a1SLionel Sambuc 	ATF_CHECK(isnan(x) != 0);
24811be35a1SLionel Sambuc 	ATF_CHECK(isnan(log1p(x)) != 0);
24911be35a1SLionel Sambuc }
25011be35a1SLionel Sambuc 
25111be35a1SLionel Sambuc ATF_TC(log1p_inf_neg);
ATF_TC_HEAD(log1p_inf_neg,tc)25211be35a1SLionel Sambuc ATF_TC_HEAD(log1p_inf_neg, tc)
25311be35a1SLionel Sambuc {
25411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1p(-Inf) == NaN");
25511be35a1SLionel Sambuc }
25611be35a1SLionel Sambuc 
ATF_TC_BODY(log1p_inf_neg,tc)25711be35a1SLionel Sambuc ATF_TC_BODY(log1p_inf_neg, tc)
25811be35a1SLionel Sambuc {
25911be35a1SLionel Sambuc 	const double x = -1.0L / 0.0L;
26011be35a1SLionel Sambuc 	const double y = log1p(x);
26111be35a1SLionel Sambuc 
26211be35a1SLionel Sambuc 	if (isnan(y) == 0) {
26311be35a1SLionel Sambuc 		atf_tc_expect_fail("PR lib/45362");
26411be35a1SLionel Sambuc 		atf_tc_fail("log1p(-Inf) != NaN");
26511be35a1SLionel Sambuc 	}
26611be35a1SLionel Sambuc }
26711be35a1SLionel Sambuc 
26811be35a1SLionel Sambuc ATF_TC(log1p_inf_pos);
ATF_TC_HEAD(log1p_inf_pos,tc)26911be35a1SLionel Sambuc ATF_TC_HEAD(log1p_inf_pos, tc)
27011be35a1SLionel Sambuc {
27111be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1p(+Inf) == +Inf");
27211be35a1SLionel Sambuc }
27311be35a1SLionel Sambuc 
ATF_TC_BODY(log1p_inf_pos,tc)27411be35a1SLionel Sambuc ATF_TC_BODY(log1p_inf_pos, tc)
27511be35a1SLionel Sambuc {
27611be35a1SLionel Sambuc 	const double x = 1.0L / 0.0L;
27711be35a1SLionel Sambuc 
27811be35a1SLionel Sambuc 	ATF_CHECK(log1p(x) == x);
27911be35a1SLionel Sambuc }
28011be35a1SLionel Sambuc 
28111be35a1SLionel Sambuc ATF_TC(log1p_one_neg);
ATF_TC_HEAD(log1p_one_neg,tc)28211be35a1SLionel Sambuc ATF_TC_HEAD(log1p_one_neg, tc)
28311be35a1SLionel Sambuc {
28411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1p(-1.0) == -HUGE_VAL");
28511be35a1SLionel Sambuc }
28611be35a1SLionel Sambuc 
ATF_TC_BODY(log1p_one_neg,tc)28711be35a1SLionel Sambuc ATF_TC_BODY(log1p_one_neg, tc)
28811be35a1SLionel Sambuc {
28911be35a1SLionel Sambuc 	const double x = log1p(-1.0);
29011be35a1SLionel Sambuc 
29111be35a1SLionel Sambuc 	if (x != -HUGE_VAL) {
29211be35a1SLionel Sambuc 		atf_tc_expect_fail("PR lib/45362");
29311be35a1SLionel Sambuc 		atf_tc_fail("log1p(-1.0) != -HUGE_VAL");
29411be35a1SLionel Sambuc 	}
29511be35a1SLionel Sambuc }
29611be35a1SLionel Sambuc 
29711be35a1SLionel Sambuc ATF_TC(log1p_zero_neg);
ATF_TC_HEAD(log1p_zero_neg,tc)29811be35a1SLionel Sambuc ATF_TC_HEAD(log1p_zero_neg, tc)
29911be35a1SLionel Sambuc {
30011be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1p(-0.0) == -0.0");
30111be35a1SLionel Sambuc }
30211be35a1SLionel Sambuc 
ATF_TC_BODY(log1p_zero_neg,tc)30311be35a1SLionel Sambuc ATF_TC_BODY(log1p_zero_neg, tc)
30411be35a1SLionel Sambuc {
30511be35a1SLionel Sambuc 	const double x = -0.0L;
30611be35a1SLionel Sambuc 
30711be35a1SLionel Sambuc 	ATF_CHECK(log1p(x) == x);
30811be35a1SLionel Sambuc }
30911be35a1SLionel Sambuc 
31011be35a1SLionel Sambuc ATF_TC(log1p_zero_pos);
ATF_TC_HEAD(log1p_zero_pos,tc)31111be35a1SLionel Sambuc ATF_TC_HEAD(log1p_zero_pos, tc)
31211be35a1SLionel Sambuc {
31311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1p(+0.0) == +0.0");
31411be35a1SLionel Sambuc }
31511be35a1SLionel Sambuc 
ATF_TC_BODY(log1p_zero_pos,tc)31611be35a1SLionel Sambuc ATF_TC_BODY(log1p_zero_pos, tc)
31711be35a1SLionel Sambuc {
31811be35a1SLionel Sambuc 	const double x = 0.0L;
31911be35a1SLionel Sambuc 
32011be35a1SLionel Sambuc 	ATF_CHECK(log1p(x) == x);
32111be35a1SLionel Sambuc }
32211be35a1SLionel Sambuc 
32311be35a1SLionel Sambuc /*
32411be35a1SLionel Sambuc  * log1pf(3)
32511be35a1SLionel Sambuc  */
32611be35a1SLionel Sambuc ATF_TC(log1pf_nan);
ATF_TC_HEAD(log1pf_nan,tc)32711be35a1SLionel Sambuc ATF_TC_HEAD(log1pf_nan, tc)
32811be35a1SLionel Sambuc {
32911be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1pf(NaN) == NaN");
33011be35a1SLionel Sambuc }
33111be35a1SLionel Sambuc 
ATF_TC_BODY(log1pf_nan,tc)33211be35a1SLionel Sambuc ATF_TC_BODY(log1pf_nan, tc)
33311be35a1SLionel Sambuc {
33411be35a1SLionel Sambuc 	const float x = 0.0L / 0.0L;
33511be35a1SLionel Sambuc 
33611be35a1SLionel Sambuc 	ATF_CHECK(isnan(x) != 0);
33711be35a1SLionel Sambuc 	ATF_CHECK(isnan(log1pf(x)) != 0);
33811be35a1SLionel Sambuc }
33911be35a1SLionel Sambuc 
34011be35a1SLionel Sambuc ATF_TC(log1pf_inf_neg);
ATF_TC_HEAD(log1pf_inf_neg,tc)34111be35a1SLionel Sambuc ATF_TC_HEAD(log1pf_inf_neg, tc)
34211be35a1SLionel Sambuc {
34311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1pf(-Inf) == NaN");
34411be35a1SLionel Sambuc }
34511be35a1SLionel Sambuc 
ATF_TC_BODY(log1pf_inf_neg,tc)34611be35a1SLionel Sambuc ATF_TC_BODY(log1pf_inf_neg, tc)
34711be35a1SLionel Sambuc {
34811be35a1SLionel Sambuc 	const float x = -1.0L / 0.0L;
34911be35a1SLionel Sambuc 	const float y = log1pf(x);
35011be35a1SLionel Sambuc 
35111be35a1SLionel Sambuc 	if (isnan(y) == 0) {
35211be35a1SLionel Sambuc 		atf_tc_expect_fail("PR lib/45362");
35311be35a1SLionel Sambuc 		atf_tc_fail("log1pf(-Inf) != NaN");
35411be35a1SLionel Sambuc 	}
35511be35a1SLionel Sambuc }
35611be35a1SLionel Sambuc 
35711be35a1SLionel Sambuc ATF_TC(log1pf_inf_pos);
ATF_TC_HEAD(log1pf_inf_pos,tc)35811be35a1SLionel Sambuc ATF_TC_HEAD(log1pf_inf_pos, tc)
35911be35a1SLionel Sambuc {
36011be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1pf(+Inf) == +Inf");
36111be35a1SLionel Sambuc }
36211be35a1SLionel Sambuc 
ATF_TC_BODY(log1pf_inf_pos,tc)36311be35a1SLionel Sambuc ATF_TC_BODY(log1pf_inf_pos, tc)
36411be35a1SLionel Sambuc {
36511be35a1SLionel Sambuc 	const float x = 1.0L / 0.0L;
36611be35a1SLionel Sambuc 
36711be35a1SLionel Sambuc 	ATF_CHECK(log1pf(x) == x);
36811be35a1SLionel Sambuc }
36911be35a1SLionel Sambuc 
37011be35a1SLionel Sambuc ATF_TC(log1pf_one_neg);
ATF_TC_HEAD(log1pf_one_neg,tc)37111be35a1SLionel Sambuc ATF_TC_HEAD(log1pf_one_neg, tc)
37211be35a1SLionel Sambuc {
37311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1pf(-1.0) == -HUGE_VALF");
37411be35a1SLionel Sambuc }
37511be35a1SLionel Sambuc 
ATF_TC_BODY(log1pf_one_neg,tc)37611be35a1SLionel Sambuc ATF_TC_BODY(log1pf_one_neg, tc)
37711be35a1SLionel Sambuc {
37811be35a1SLionel Sambuc 	const float x = log1pf(-1.0);
37911be35a1SLionel Sambuc 
38011be35a1SLionel Sambuc 	if (x != -HUGE_VALF) {
38111be35a1SLionel Sambuc 		atf_tc_expect_fail("PR lib/45362");
38211be35a1SLionel Sambuc 		atf_tc_fail("log1pf(-1.0) != -HUGE_VALF");
38311be35a1SLionel Sambuc 	}
38411be35a1SLionel Sambuc }
38511be35a1SLionel Sambuc 
38611be35a1SLionel Sambuc ATF_TC(log1pf_zero_neg);
ATF_TC_HEAD(log1pf_zero_neg,tc)38711be35a1SLionel Sambuc ATF_TC_HEAD(log1pf_zero_neg, tc)
38811be35a1SLionel Sambuc {
38911be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1pf(-0.0) == -0.0");
39011be35a1SLionel Sambuc }
39111be35a1SLionel Sambuc 
ATF_TC_BODY(log1pf_zero_neg,tc)39211be35a1SLionel Sambuc ATF_TC_BODY(log1pf_zero_neg, tc)
39311be35a1SLionel Sambuc {
39411be35a1SLionel Sambuc 	const float x = -0.0L;
39511be35a1SLionel Sambuc 
39611be35a1SLionel Sambuc 	ATF_CHECK(log1pf(x) == x);
39711be35a1SLionel Sambuc }
39811be35a1SLionel Sambuc 
39911be35a1SLionel Sambuc ATF_TC(log1pf_zero_pos);
ATF_TC_HEAD(log1pf_zero_pos,tc)40011be35a1SLionel Sambuc ATF_TC_HEAD(log1pf_zero_pos, tc)
40111be35a1SLionel Sambuc {
40211be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log1pf(+0.0) == +0.0");
40311be35a1SLionel Sambuc }
40411be35a1SLionel Sambuc 
ATF_TC_BODY(log1pf_zero_pos,tc)40511be35a1SLionel Sambuc ATF_TC_BODY(log1pf_zero_pos, tc)
40611be35a1SLionel Sambuc {
40711be35a1SLionel Sambuc 	const float x = 0.0L;
40811be35a1SLionel Sambuc 
40911be35a1SLionel Sambuc 	ATF_CHECK(log1pf(x) == x);
41011be35a1SLionel Sambuc }
41111be35a1SLionel Sambuc 
41211be35a1SLionel Sambuc /*
41311be35a1SLionel Sambuc  * log2(3)
41411be35a1SLionel Sambuc  */
41511be35a1SLionel Sambuc ATF_TC(log2_base);
ATF_TC_HEAD(log2_base,tc)41611be35a1SLionel Sambuc ATF_TC_HEAD(log2_base, tc)
41711be35a1SLionel Sambuc {
41811be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2(2) == 1");
41911be35a1SLionel Sambuc }
42011be35a1SLionel Sambuc 
ATF_TC_BODY(log2_base,tc)42111be35a1SLionel Sambuc ATF_TC_BODY(log2_base, tc)
42211be35a1SLionel Sambuc {
42311be35a1SLionel Sambuc 	ATF_CHECK(log2(2.0) == 1.0);
42411be35a1SLionel Sambuc }
42511be35a1SLionel Sambuc 
42611be35a1SLionel Sambuc ATF_TC(log2_nan);
ATF_TC_HEAD(log2_nan,tc)42711be35a1SLionel Sambuc ATF_TC_HEAD(log2_nan, tc)
42811be35a1SLionel Sambuc {
42911be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2(NaN) == NaN");
43011be35a1SLionel Sambuc }
43111be35a1SLionel Sambuc 
ATF_TC_BODY(log2_nan,tc)43211be35a1SLionel Sambuc ATF_TC_BODY(log2_nan, tc)
43311be35a1SLionel Sambuc {
43411be35a1SLionel Sambuc 	const double x = 0.0L / 0.0L;
43511be35a1SLionel Sambuc 
43611be35a1SLionel Sambuc 	ATF_CHECK(isnan(x) != 0);
43711be35a1SLionel Sambuc 	ATF_CHECK(isnan(log2(x)) != 0);
43811be35a1SLionel Sambuc }
43911be35a1SLionel Sambuc 
44011be35a1SLionel Sambuc ATF_TC(log2_inf_neg);
ATF_TC_HEAD(log2_inf_neg,tc)44111be35a1SLionel Sambuc ATF_TC_HEAD(log2_inf_neg, tc)
44211be35a1SLionel Sambuc {
44311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2(-Inf) == NaN");
44411be35a1SLionel Sambuc }
44511be35a1SLionel Sambuc 
ATF_TC_BODY(log2_inf_neg,tc)44611be35a1SLionel Sambuc ATF_TC_BODY(log2_inf_neg, tc)
44711be35a1SLionel Sambuc {
44811be35a1SLionel Sambuc 	const double x = -1.0L / 0.0L;
44911be35a1SLionel Sambuc 	const double y = log2(x);
45011be35a1SLionel Sambuc 
45111be35a1SLionel Sambuc 	ATF_CHECK(isnan(y) != 0);
45211be35a1SLionel Sambuc }
45311be35a1SLionel Sambuc 
45411be35a1SLionel Sambuc ATF_TC(log2_inf_pos);
ATF_TC_HEAD(log2_inf_pos,tc)45511be35a1SLionel Sambuc ATF_TC_HEAD(log2_inf_pos, tc)
45611be35a1SLionel Sambuc {
45711be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2(+Inf) == +Inf");
45811be35a1SLionel Sambuc }
45911be35a1SLionel Sambuc 
ATF_TC_BODY(log2_inf_pos,tc)46011be35a1SLionel Sambuc ATF_TC_BODY(log2_inf_pos, tc)
46111be35a1SLionel Sambuc {
46211be35a1SLionel Sambuc 	const double x = 1.0L / 0.0L;
46311be35a1SLionel Sambuc 
46411be35a1SLionel Sambuc 	ATF_CHECK(log2(x) == x);
46511be35a1SLionel Sambuc }
46611be35a1SLionel Sambuc 
46711be35a1SLionel Sambuc ATF_TC(log2_one_pos);
ATF_TC_HEAD(log2_one_pos,tc)46811be35a1SLionel Sambuc ATF_TC_HEAD(log2_one_pos, tc)
46911be35a1SLionel Sambuc {
47011be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2(1.0) == +0.0");
47111be35a1SLionel Sambuc }
47211be35a1SLionel Sambuc 
ATF_TC_BODY(log2_one_pos,tc)47311be35a1SLionel Sambuc ATF_TC_BODY(log2_one_pos, tc)
47411be35a1SLionel Sambuc {
47511be35a1SLionel Sambuc 	const double x = log2(1.0);
47611be35a1SLionel Sambuc 	const double y = 0.0L;
47711be35a1SLionel Sambuc 
47811be35a1SLionel Sambuc 	ATF_CHECK(x == y);
47911be35a1SLionel Sambuc 	ATF_CHECK(signbit(x) == 0);
48011be35a1SLionel Sambuc 	ATF_CHECK(signbit(y) == 0);
48111be35a1SLionel Sambuc }
48211be35a1SLionel Sambuc 
48311be35a1SLionel Sambuc ATF_TC(log2_zero_neg);
ATF_TC_HEAD(log2_zero_neg,tc)48411be35a1SLionel Sambuc ATF_TC_HEAD(log2_zero_neg, tc)
48511be35a1SLionel Sambuc {
48611be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2(-0.0) == -HUGE_VAL");
48711be35a1SLionel Sambuc }
48811be35a1SLionel Sambuc 
ATF_TC_BODY(log2_zero_neg,tc)48911be35a1SLionel Sambuc ATF_TC_BODY(log2_zero_neg, tc)
49011be35a1SLionel Sambuc {
49111be35a1SLionel Sambuc 	const double x = -0.0L;
49211be35a1SLionel Sambuc 
49311be35a1SLionel Sambuc 	ATF_CHECK(log2(x) == -HUGE_VAL);
49411be35a1SLionel Sambuc }
49511be35a1SLionel Sambuc 
49611be35a1SLionel Sambuc ATF_TC(log2_zero_pos);
ATF_TC_HEAD(log2_zero_pos,tc)49711be35a1SLionel Sambuc ATF_TC_HEAD(log2_zero_pos, tc)
49811be35a1SLionel Sambuc {
49911be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2(+0.0) == -HUGE_VAL");
50011be35a1SLionel Sambuc }
50111be35a1SLionel Sambuc 
ATF_TC_BODY(log2_zero_pos,tc)50211be35a1SLionel Sambuc ATF_TC_BODY(log2_zero_pos, tc)
50311be35a1SLionel Sambuc {
50411be35a1SLionel Sambuc 	const double x = 0.0L;
50511be35a1SLionel Sambuc 
50611be35a1SLionel Sambuc 	ATF_CHECK(log2(x) == -HUGE_VAL);
50711be35a1SLionel Sambuc }
50811be35a1SLionel Sambuc 
50911be35a1SLionel Sambuc /*
51011be35a1SLionel Sambuc  * log2f(3)
51111be35a1SLionel Sambuc  */
51211be35a1SLionel Sambuc ATF_TC(log2f_base);
ATF_TC_HEAD(log2f_base,tc)51311be35a1SLionel Sambuc ATF_TC_HEAD(log2f_base, tc)
51411be35a1SLionel Sambuc {
51511be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2f(2) == 1");
51611be35a1SLionel Sambuc }
51711be35a1SLionel Sambuc 
ATF_TC_BODY(log2f_base,tc)51811be35a1SLionel Sambuc ATF_TC_BODY(log2f_base, tc)
51911be35a1SLionel Sambuc {
52011be35a1SLionel Sambuc 	ATF_CHECK(log2f(2.0) == 1.0);
52111be35a1SLionel Sambuc }
52211be35a1SLionel Sambuc 
52311be35a1SLionel Sambuc ATF_TC(log2f_nan);
ATF_TC_HEAD(log2f_nan,tc)52411be35a1SLionel Sambuc ATF_TC_HEAD(log2f_nan, tc)
52511be35a1SLionel Sambuc {
52611be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2f(NaN) == NaN");
52711be35a1SLionel Sambuc }
52811be35a1SLionel Sambuc 
ATF_TC_BODY(log2f_nan,tc)52911be35a1SLionel Sambuc ATF_TC_BODY(log2f_nan, tc)
53011be35a1SLionel Sambuc {
53111be35a1SLionel Sambuc 	const float x = 0.0L / 0.0L;
53211be35a1SLionel Sambuc 
53311be35a1SLionel Sambuc 	ATF_CHECK(isnan(x) != 0);
53411be35a1SLionel Sambuc 	ATF_CHECK(isnan(log2f(x)) != 0);
53511be35a1SLionel Sambuc }
53611be35a1SLionel Sambuc 
53711be35a1SLionel Sambuc ATF_TC(log2f_inf_neg);
ATF_TC_HEAD(log2f_inf_neg,tc)53811be35a1SLionel Sambuc ATF_TC_HEAD(log2f_inf_neg, tc)
53911be35a1SLionel Sambuc {
54011be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2f(-Inf) == NaN");
54111be35a1SLionel Sambuc }
54211be35a1SLionel Sambuc 
ATF_TC_BODY(log2f_inf_neg,tc)54311be35a1SLionel Sambuc ATF_TC_BODY(log2f_inf_neg, tc)
54411be35a1SLionel Sambuc {
54511be35a1SLionel Sambuc 	const float x = -1.0L / 0.0L;
54611be35a1SLionel Sambuc 	const float y = log2f(x);
54711be35a1SLionel Sambuc 
54811be35a1SLionel Sambuc 	ATF_CHECK(isnan(y) != 0);
54911be35a1SLionel Sambuc }
55011be35a1SLionel Sambuc 
55111be35a1SLionel Sambuc ATF_TC(log2f_inf_pos);
ATF_TC_HEAD(log2f_inf_pos,tc)55211be35a1SLionel Sambuc ATF_TC_HEAD(log2f_inf_pos, tc)
55311be35a1SLionel Sambuc {
55411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2f(+Inf) == +Inf");
55511be35a1SLionel Sambuc }
55611be35a1SLionel Sambuc 
ATF_TC_BODY(log2f_inf_pos,tc)55711be35a1SLionel Sambuc ATF_TC_BODY(log2f_inf_pos, tc)
55811be35a1SLionel Sambuc {
55911be35a1SLionel Sambuc 	const float x = 1.0L / 0.0L;
56011be35a1SLionel Sambuc 
56111be35a1SLionel Sambuc 	ATF_CHECK(log2f(x) == x);
56211be35a1SLionel Sambuc }
56311be35a1SLionel Sambuc 
56411be35a1SLionel Sambuc ATF_TC(log2f_one_pos);
ATF_TC_HEAD(log2f_one_pos,tc)56511be35a1SLionel Sambuc ATF_TC_HEAD(log2f_one_pos, tc)
56611be35a1SLionel Sambuc {
56711be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2f(1.0) == +0.0");
56811be35a1SLionel Sambuc }
56911be35a1SLionel Sambuc 
ATF_TC_BODY(log2f_one_pos,tc)57011be35a1SLionel Sambuc ATF_TC_BODY(log2f_one_pos, tc)
57111be35a1SLionel Sambuc {
57211be35a1SLionel Sambuc 	const float x = log2f(1.0);
57311be35a1SLionel Sambuc 	const float y = 0.0L;
57411be35a1SLionel Sambuc 
57511be35a1SLionel Sambuc 	ATF_CHECK(x == y);
57611be35a1SLionel Sambuc 	ATF_CHECK(signbit(x) == 0);
57711be35a1SLionel Sambuc 	ATF_CHECK(signbit(y) == 0);
57811be35a1SLionel Sambuc }
57911be35a1SLionel Sambuc 
58011be35a1SLionel Sambuc ATF_TC(log2f_zero_neg);
ATF_TC_HEAD(log2f_zero_neg,tc)58111be35a1SLionel Sambuc ATF_TC_HEAD(log2f_zero_neg, tc)
58211be35a1SLionel Sambuc {
58311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2f(-0.0) == -HUGE_VALF");
58411be35a1SLionel Sambuc }
58511be35a1SLionel Sambuc 
ATF_TC_BODY(log2f_zero_neg,tc)58611be35a1SLionel Sambuc ATF_TC_BODY(log2f_zero_neg, tc)
58711be35a1SLionel Sambuc {
58811be35a1SLionel Sambuc 	const float x = -0.0L;
58911be35a1SLionel Sambuc 
59011be35a1SLionel Sambuc 	ATF_CHECK(log2f(x) == -HUGE_VALF);
59111be35a1SLionel Sambuc }
59211be35a1SLionel Sambuc 
59311be35a1SLionel Sambuc ATF_TC(log2f_zero_pos);
ATF_TC_HEAD(log2f_zero_pos,tc)59411be35a1SLionel Sambuc ATF_TC_HEAD(log2f_zero_pos, tc)
59511be35a1SLionel Sambuc {
59611be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log2f(+0.0) == -HUGE_VALF");
59711be35a1SLionel Sambuc }
59811be35a1SLionel Sambuc 
ATF_TC_BODY(log2f_zero_pos,tc)59911be35a1SLionel Sambuc ATF_TC_BODY(log2f_zero_pos, tc)
60011be35a1SLionel Sambuc {
60111be35a1SLionel Sambuc 	const float x = 0.0L;
60211be35a1SLionel Sambuc 
60311be35a1SLionel Sambuc 	ATF_CHECK(log2f(x) == -HUGE_VALF);
60411be35a1SLionel Sambuc }
60511be35a1SLionel Sambuc 
60611be35a1SLionel Sambuc /*
60711be35a1SLionel Sambuc  * log(3)
60811be35a1SLionel Sambuc  */
60911be35a1SLionel Sambuc ATF_TC(log_base);
ATF_TC_HEAD(log_base,tc)61011be35a1SLionel Sambuc ATF_TC_HEAD(log_base, tc)
61111be35a1SLionel Sambuc {
61211be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log(e) == 1");
61311be35a1SLionel Sambuc }
61411be35a1SLionel Sambuc 
ATF_TC_BODY(log_base,tc)61511be35a1SLionel Sambuc ATF_TC_BODY(log_base, tc)
61611be35a1SLionel Sambuc {
61711be35a1SLionel Sambuc 	const double eps = 1.0e-38;
61811be35a1SLionel Sambuc 
61911be35a1SLionel Sambuc 	if (fabs(log(M_E) - 1.0) > eps)
62011be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("log(e) != 1");
62111be35a1SLionel Sambuc }
62211be35a1SLionel Sambuc 
62311be35a1SLionel Sambuc ATF_TC(log_nan);
ATF_TC_HEAD(log_nan,tc)62411be35a1SLionel Sambuc ATF_TC_HEAD(log_nan, tc)
62511be35a1SLionel Sambuc {
62611be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log(NaN) == NaN");
62711be35a1SLionel Sambuc }
62811be35a1SLionel Sambuc 
ATF_TC_BODY(log_nan,tc)62911be35a1SLionel Sambuc ATF_TC_BODY(log_nan, tc)
63011be35a1SLionel Sambuc {
63111be35a1SLionel Sambuc 	const double x = 0.0L / 0.0L;
63211be35a1SLionel Sambuc 
63311be35a1SLionel Sambuc 	ATF_CHECK(isnan(x) != 0);
63411be35a1SLionel Sambuc 	ATF_CHECK(isnan(log(x)) != 0);
63511be35a1SLionel Sambuc }
63611be35a1SLionel Sambuc 
63711be35a1SLionel Sambuc ATF_TC(log_inf_neg);
ATF_TC_HEAD(log_inf_neg,tc)63811be35a1SLionel Sambuc ATF_TC_HEAD(log_inf_neg, tc)
63911be35a1SLionel Sambuc {
64011be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log(-Inf) == NaN");
64111be35a1SLionel Sambuc }
64211be35a1SLionel Sambuc 
ATF_TC_BODY(log_inf_neg,tc)64311be35a1SLionel Sambuc ATF_TC_BODY(log_inf_neg, tc)
64411be35a1SLionel Sambuc {
64511be35a1SLionel Sambuc 	const double x = -1.0L / 0.0L;
64611be35a1SLionel Sambuc 	const double y = log(x);
64711be35a1SLionel Sambuc 
64811be35a1SLionel Sambuc 	ATF_CHECK(isnan(y) != 0);
64911be35a1SLionel Sambuc }
65011be35a1SLionel Sambuc 
65111be35a1SLionel Sambuc ATF_TC(log_inf_pos);
ATF_TC_HEAD(log_inf_pos,tc)65211be35a1SLionel Sambuc ATF_TC_HEAD(log_inf_pos, tc)
65311be35a1SLionel Sambuc {
65411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log(+Inf) == +Inf");
65511be35a1SLionel Sambuc }
65611be35a1SLionel Sambuc 
ATF_TC_BODY(log_inf_pos,tc)65711be35a1SLionel Sambuc ATF_TC_BODY(log_inf_pos, tc)
65811be35a1SLionel Sambuc {
65911be35a1SLionel Sambuc 	const double x = 1.0L / 0.0L;
66011be35a1SLionel Sambuc 
66111be35a1SLionel Sambuc 	ATF_CHECK(log(x) == x);
66211be35a1SLionel Sambuc }
66311be35a1SLionel Sambuc 
66411be35a1SLionel Sambuc ATF_TC(log_one_pos);
ATF_TC_HEAD(log_one_pos,tc)66511be35a1SLionel Sambuc ATF_TC_HEAD(log_one_pos, tc)
66611be35a1SLionel Sambuc {
66711be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log(1.0) == +0.0");
66811be35a1SLionel Sambuc }
66911be35a1SLionel Sambuc 
ATF_TC_BODY(log_one_pos,tc)67011be35a1SLionel Sambuc ATF_TC_BODY(log_one_pos, tc)
67111be35a1SLionel Sambuc {
67211be35a1SLionel Sambuc 	const double x = log(1.0);
67311be35a1SLionel Sambuc 	const double y = 0.0L;
67411be35a1SLionel Sambuc 
67511be35a1SLionel Sambuc 	ATF_CHECK(x == y);
67611be35a1SLionel Sambuc 	ATF_CHECK(signbit(x) == 0);
67711be35a1SLionel Sambuc 	ATF_CHECK(signbit(y) == 0);
67811be35a1SLionel Sambuc }
67911be35a1SLionel Sambuc 
68011be35a1SLionel Sambuc ATF_TC(log_zero_neg);
ATF_TC_HEAD(log_zero_neg,tc)68111be35a1SLionel Sambuc ATF_TC_HEAD(log_zero_neg, tc)
68211be35a1SLionel Sambuc {
68311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log(-0.0) == -HUGE_VAL");
68411be35a1SLionel Sambuc }
68511be35a1SLionel Sambuc 
ATF_TC_BODY(log_zero_neg,tc)68611be35a1SLionel Sambuc ATF_TC_BODY(log_zero_neg, tc)
68711be35a1SLionel Sambuc {
68811be35a1SLionel Sambuc 	const double x = -0.0L;
68911be35a1SLionel Sambuc 
69011be35a1SLionel Sambuc 	ATF_CHECK(log(x) == -HUGE_VAL);
69111be35a1SLionel Sambuc }
69211be35a1SLionel Sambuc 
69311be35a1SLionel Sambuc ATF_TC(log_zero_pos);
ATF_TC_HEAD(log_zero_pos,tc)69411be35a1SLionel Sambuc ATF_TC_HEAD(log_zero_pos, tc)
69511be35a1SLionel Sambuc {
69611be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test log(+0.0) == -HUGE_VAL");
69711be35a1SLionel Sambuc }
69811be35a1SLionel Sambuc 
ATF_TC_BODY(log_zero_pos,tc)69911be35a1SLionel Sambuc ATF_TC_BODY(log_zero_pos, tc)
70011be35a1SLionel Sambuc {
70111be35a1SLionel Sambuc 	const double x = 0.0L;
70211be35a1SLionel Sambuc 
70311be35a1SLionel Sambuc 	ATF_CHECK(log(x) == -HUGE_VAL);
70411be35a1SLionel Sambuc }
70511be35a1SLionel Sambuc 
70611be35a1SLionel Sambuc /*
70711be35a1SLionel Sambuc  * logf(3)
70811be35a1SLionel Sambuc  */
70911be35a1SLionel Sambuc ATF_TC(logf_base);
ATF_TC_HEAD(logf_base,tc)71011be35a1SLionel Sambuc ATF_TC_HEAD(logf_base, tc)
71111be35a1SLionel Sambuc {
71211be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test logf(e) == 1");
71311be35a1SLionel Sambuc }
71411be35a1SLionel Sambuc 
ATF_TC_BODY(logf_base,tc)71511be35a1SLionel Sambuc ATF_TC_BODY(logf_base, tc)
71611be35a1SLionel Sambuc {
71711be35a1SLionel Sambuc 	const float eps = 1.0e-7;
71811be35a1SLionel Sambuc 
719*0a6a1f1dSLionel Sambuc 	if (fabsf(logf(M_E) - 1.0f) > eps)
72011be35a1SLionel Sambuc 		atf_tc_fail_nonfatal("logf(e) != 1");
72111be35a1SLionel Sambuc }
72211be35a1SLionel Sambuc 
72311be35a1SLionel Sambuc ATF_TC(logf_nan);
ATF_TC_HEAD(logf_nan,tc)72411be35a1SLionel Sambuc ATF_TC_HEAD(logf_nan, tc)
72511be35a1SLionel Sambuc {
72611be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test logf(NaN) == NaN");
72711be35a1SLionel Sambuc }
72811be35a1SLionel Sambuc 
ATF_TC_BODY(logf_nan,tc)72911be35a1SLionel Sambuc ATF_TC_BODY(logf_nan, tc)
73011be35a1SLionel Sambuc {
73111be35a1SLionel Sambuc 	const float x = 0.0L / 0.0L;
73211be35a1SLionel Sambuc 
73311be35a1SLionel Sambuc 	ATF_CHECK(isnan(x) != 0);
73411be35a1SLionel Sambuc 	ATF_CHECK(isnan(logf(x)) != 0);
73511be35a1SLionel Sambuc }
73611be35a1SLionel Sambuc 
73711be35a1SLionel Sambuc ATF_TC(logf_inf_neg);
ATF_TC_HEAD(logf_inf_neg,tc)73811be35a1SLionel Sambuc ATF_TC_HEAD(logf_inf_neg, tc)
73911be35a1SLionel Sambuc {
74011be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test logf(-Inf) == NaN");
74111be35a1SLionel Sambuc }
74211be35a1SLionel Sambuc 
ATF_TC_BODY(logf_inf_neg,tc)74311be35a1SLionel Sambuc ATF_TC_BODY(logf_inf_neg, tc)
74411be35a1SLionel Sambuc {
74511be35a1SLionel Sambuc 	const float x = -1.0L / 0.0L;
74611be35a1SLionel Sambuc 	const float y = logf(x);
74711be35a1SLionel Sambuc 
74811be35a1SLionel Sambuc 	ATF_CHECK(isnan(y) != 0);
74911be35a1SLionel Sambuc }
75011be35a1SLionel Sambuc 
75111be35a1SLionel Sambuc ATF_TC(logf_inf_pos);
ATF_TC_HEAD(logf_inf_pos,tc)75211be35a1SLionel Sambuc ATF_TC_HEAD(logf_inf_pos, tc)
75311be35a1SLionel Sambuc {
75411be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test logf(+Inf) == +Inf");
75511be35a1SLionel Sambuc }
75611be35a1SLionel Sambuc 
ATF_TC_BODY(logf_inf_pos,tc)75711be35a1SLionel Sambuc ATF_TC_BODY(logf_inf_pos, tc)
75811be35a1SLionel Sambuc {
75911be35a1SLionel Sambuc 	const float x = 1.0L / 0.0L;
76011be35a1SLionel Sambuc 
76111be35a1SLionel Sambuc 	ATF_CHECK(logf(x) == x);
76211be35a1SLionel Sambuc }
76311be35a1SLionel Sambuc 
76411be35a1SLionel Sambuc ATF_TC(logf_one_pos);
ATF_TC_HEAD(logf_one_pos,tc)76511be35a1SLionel Sambuc ATF_TC_HEAD(logf_one_pos, tc)
76611be35a1SLionel Sambuc {
76711be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test logf(1.0) == +0.0");
76811be35a1SLionel Sambuc }
76911be35a1SLionel Sambuc 
ATF_TC_BODY(logf_one_pos,tc)77011be35a1SLionel Sambuc ATF_TC_BODY(logf_one_pos, tc)
77111be35a1SLionel Sambuc {
77211be35a1SLionel Sambuc 	const float x = logf(1.0);
77311be35a1SLionel Sambuc 	const float y = 0.0L;
77411be35a1SLionel Sambuc 
77511be35a1SLionel Sambuc 	ATF_CHECK(x == y);
77611be35a1SLionel Sambuc 	ATF_CHECK(signbit(x) == 0);
77711be35a1SLionel Sambuc 	ATF_CHECK(signbit(y) == 0);
77811be35a1SLionel Sambuc }
77911be35a1SLionel Sambuc 
78011be35a1SLionel Sambuc ATF_TC(logf_zero_neg);
ATF_TC_HEAD(logf_zero_neg,tc)78111be35a1SLionel Sambuc ATF_TC_HEAD(logf_zero_neg, tc)
78211be35a1SLionel Sambuc {
78311be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test logf(-0.0) == -HUGE_VALF");
78411be35a1SLionel Sambuc }
78511be35a1SLionel Sambuc 
ATF_TC_BODY(logf_zero_neg,tc)78611be35a1SLionel Sambuc ATF_TC_BODY(logf_zero_neg, tc)
78711be35a1SLionel Sambuc {
78811be35a1SLionel Sambuc 	const float x = -0.0L;
78911be35a1SLionel Sambuc 
79011be35a1SLionel Sambuc 	ATF_CHECK(logf(x) == -HUGE_VALF);
79111be35a1SLionel Sambuc }
79211be35a1SLionel Sambuc 
79311be35a1SLionel Sambuc ATF_TC(logf_zero_pos);
ATF_TC_HEAD(logf_zero_pos,tc)79411be35a1SLionel Sambuc ATF_TC_HEAD(logf_zero_pos, tc)
79511be35a1SLionel Sambuc {
79611be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Test logf(+0.0) == -HUGE_VALF");
79711be35a1SLionel Sambuc }
79811be35a1SLionel Sambuc 
ATF_TC_BODY(logf_zero_pos,tc)79911be35a1SLionel Sambuc ATF_TC_BODY(logf_zero_pos, tc)
80011be35a1SLionel Sambuc {
80111be35a1SLionel Sambuc 	const float x = 0.0L;
80211be35a1SLionel Sambuc 
80311be35a1SLionel Sambuc 	ATF_CHECK(logf(x) == -HUGE_VALF);
80411be35a1SLionel Sambuc }
80511be35a1SLionel Sambuc 
ATF_TP_ADD_TCS(tp)80611be35a1SLionel Sambuc ATF_TP_ADD_TCS(tp)
80711be35a1SLionel Sambuc {
80811be35a1SLionel Sambuc 
80911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10_base);
81011be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10_nan);
81111be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10_inf_neg);
81211be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10_inf_pos);
81311be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10_one_pos);
81411be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10_zero_neg);
81511be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10_zero_pos);
81611be35a1SLionel Sambuc 
81711be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10f_base);
81811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10f_nan);
81911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10f_inf_neg);
82011be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10f_inf_pos);
82111be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10f_one_pos);
82211be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10f_zero_neg);
82311be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log10f_zero_pos);
82411be35a1SLionel Sambuc 
82511be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1p_nan);
82611be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1p_inf_neg);
82711be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1p_inf_pos);
82811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1p_one_neg);
82911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1p_zero_neg);
83011be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1p_zero_pos);
83111be35a1SLionel Sambuc 
83211be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1pf_nan);
83311be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1pf_inf_neg);
83411be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1pf_inf_pos);
83511be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1pf_one_neg);
83611be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1pf_zero_neg);
83711be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log1pf_zero_pos);
83811be35a1SLionel Sambuc 
83911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2_base);
84011be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2_nan);
84111be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2_inf_neg);
84211be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2_inf_pos);
84311be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2_one_pos);
84411be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2_zero_neg);
84511be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2_zero_pos);
84611be35a1SLionel Sambuc 
84711be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2f_base);
84811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2f_nan);
84911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2f_inf_neg);
85011be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2f_inf_pos);
85111be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2f_one_pos);
85211be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2f_zero_neg);
85311be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log2f_zero_pos);
85411be35a1SLionel Sambuc 
85511be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log_base);
85611be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log_nan);
85711be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log_inf_neg);
85811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log_inf_pos);
85911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log_one_pos);
86011be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log_zero_neg);
86111be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, log_zero_pos);
86211be35a1SLionel Sambuc 
86311be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, logf_base);
86411be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, logf_nan);
86511be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, logf_inf_neg);
86611be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, logf_inf_pos);
86711be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, logf_one_pos);
86811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, logf_zero_neg);
86911be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, logf_zero_pos);
87011be35a1SLionel Sambuc 
87111be35a1SLionel Sambuc 	return atf_no_error();
87211be35a1SLionel Sambuc }
873