xref: /freebsd/contrib/netbsd-tests/lib/libm/t_log.c (revision 62cfcf62f627e5093fb37026a6d8c98e4d2ef04c)
1 /* $NetBSD: t_log.c,v 1.13 2015/02/09 19:39:48 martin Exp $ */
2 
3 /*-
4  * Copyright (c) 2011 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jukka Ruohonen.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 #include <sys/cdefs.h>
32 __RCSID("$NetBSD: t_log.c,v 1.13 2015/02/09 19:39:48 martin Exp $");
33 
34 #include <atf-c.h>
35 
36 #include <math.h>
37 #include <stdio.h>
38 #include <string.h>
39 
40 /*
41  * log10(3)
42  */
43 ATF_TC(log10_base);
44 ATF_TC_HEAD(log10_base, tc)
45 {
46 	atf_tc_set_md_var(tc, "descr", "Test log10(10) == 1");
47 }
48 
49 ATF_TC_BODY(log10_base, tc)
50 {
51 	ATF_CHECK(log10(10.0) == 1.0);
52 }
53 
54 ATF_TC(log10_nan);
55 ATF_TC_HEAD(log10_nan, tc)
56 {
57 	atf_tc_set_md_var(tc, "descr", "Test log10(NaN) == NaN");
58 }
59 
60 ATF_TC_BODY(log10_nan, tc)
61 {
62 	const double x = 0.0L / 0.0L;
63 
64 	ATF_CHECK(isnan(x) != 0);
65 	ATF_CHECK(isnan(log10(x)) != 0);
66 }
67 
68 ATF_TC(log10_inf_neg);
69 ATF_TC_HEAD(log10_inf_neg, tc)
70 {
71 	atf_tc_set_md_var(tc, "descr", "Test log10(-Inf) == NaN");
72 }
73 
74 ATF_TC_BODY(log10_inf_neg, tc)
75 {
76 	const double x = -1.0L / 0.0L;
77 	const double y = log10(x);
78 
79 	ATF_CHECK(isnan(y) != 0);
80 }
81 
82 ATF_TC(log10_inf_pos);
83 ATF_TC_HEAD(log10_inf_pos, tc)
84 {
85 	atf_tc_set_md_var(tc, "descr", "Test log10(+Inf) == +Inf");
86 }
87 
88 ATF_TC_BODY(log10_inf_pos, tc)
89 {
90 	const double x = 1.0L / 0.0L;
91 
92 	ATF_CHECK(log10(x) == x);
93 }
94 
95 ATF_TC(log10_one_pos);
96 ATF_TC_HEAD(log10_one_pos, tc)
97 {
98 	atf_tc_set_md_var(tc, "descr", "Test log10(1.0) == +0.0");
99 }
100 
101 ATF_TC_BODY(log10_one_pos, tc)
102 {
103 	const double x = log10(1.0);
104 	const double y = 0.0L;
105 
106 	ATF_CHECK(x == y);
107 	ATF_CHECK(signbit(x) == 0);
108 	ATF_CHECK(signbit(y) == 0);
109 }
110 
111 ATF_TC(log10_zero_neg);
112 ATF_TC_HEAD(log10_zero_neg, tc)
113 {
114 	atf_tc_set_md_var(tc, "descr", "Test log10(-0.0) == -HUGE_VAL");
115 }
116 
117 ATF_TC_BODY(log10_zero_neg, tc)
118 {
119 	const double x = -0.0L;
120 
121 	ATF_CHECK(log10(x) == -HUGE_VAL);
122 }
123 
124 ATF_TC(log10_zero_pos);
125 ATF_TC_HEAD(log10_zero_pos, tc)
126 {
127 	atf_tc_set_md_var(tc, "descr", "Test log10(+0.0) == -HUGE_VAL");
128 }
129 
130 ATF_TC_BODY(log10_zero_pos, tc)
131 {
132 	const double x = 0.0L;
133 
134 	ATF_CHECK(log10(x) == -HUGE_VAL);
135 }
136 
137 /*
138  * log10f(3)
139  */
140 ATF_TC(log10f_base);
141 ATF_TC_HEAD(log10f_base, tc)
142 {
143 	atf_tc_set_md_var(tc, "descr", "Test log10f(10) == 1");
144 }
145 
146 ATF_TC_BODY(log10f_base, tc)
147 {
148 	ATF_CHECK(log10f(10.0) == 1.0);
149 }
150 
151 ATF_TC(log10f_nan);
152 ATF_TC_HEAD(log10f_nan, tc)
153 {
154 	atf_tc_set_md_var(tc, "descr", "Test log10f(NaN) == NaN");
155 }
156 
157 ATF_TC_BODY(log10f_nan, tc)
158 {
159 	const float x = 0.0L / 0.0L;
160 
161 	ATF_CHECK(isnan(x) != 0);
162 	ATF_CHECK(isnan(log10f(x)) != 0);
163 }
164 
165 ATF_TC(log10f_inf_neg);
166 ATF_TC_HEAD(log10f_inf_neg, tc)
167 {
168 	atf_tc_set_md_var(tc, "descr", "Test log10f(-Inf) == NaN");
169 }
170 
171 ATF_TC_BODY(log10f_inf_neg, tc)
172 {
173 	const float x = -1.0L / 0.0L;
174 	const float y = log10f(x);
175 
176 	ATF_CHECK(isnan(y) != 0);
177 }
178 
179 ATF_TC(log10f_inf_pos);
180 ATF_TC_HEAD(log10f_inf_pos, tc)
181 {
182 	atf_tc_set_md_var(tc, "descr", "Test log10f(+Inf) == +Inf");
183 }
184 
185 ATF_TC_BODY(log10f_inf_pos, tc)
186 {
187 	const float x = 1.0L / 0.0L;
188 
189 	ATF_CHECK(log10f(x) == x);
190 }
191 
192 ATF_TC(log10f_one_pos);
193 ATF_TC_HEAD(log10f_one_pos, tc)
194 {
195 	atf_tc_set_md_var(tc, "descr", "Test log10f(1.0) == +0.0");
196 }
197 
198 ATF_TC_BODY(log10f_one_pos, tc)
199 {
200 	const float x = log10f(1.0);
201 	const float y = 0.0L;
202 
203 	ATF_CHECK(x == y);
204 	ATF_CHECK(signbit(x) == 0);
205 	ATF_CHECK(signbit(y) == 0);
206 }
207 
208 ATF_TC(log10f_zero_neg);
209 ATF_TC_HEAD(log10f_zero_neg, tc)
210 {
211 	atf_tc_set_md_var(tc, "descr", "Test log10f(-0.0) == -HUGE_VALF");
212 }
213 
214 ATF_TC_BODY(log10f_zero_neg, tc)
215 {
216 	const float x = -0.0L;
217 
218 	ATF_CHECK(log10f(x) == -HUGE_VALF);
219 }
220 
221 ATF_TC(log10f_zero_pos);
222 ATF_TC_HEAD(log10f_zero_pos, tc)
223 {
224 	atf_tc_set_md_var(tc, "descr", "Test log10f(+0.0) == -HUGE_VALF");
225 }
226 
227 ATF_TC_BODY(log10f_zero_pos, tc)
228 {
229 	const float x = 0.0L;
230 
231 	ATF_CHECK(log10f(x) == -HUGE_VALF);
232 }
233 
234 /*
235  * log1p(3)
236  */
237 ATF_TC(log1p_nan);
238 ATF_TC_HEAD(log1p_nan, tc)
239 {
240 	atf_tc_set_md_var(tc, "descr", "Test log1p(NaN) == NaN");
241 }
242 
243 ATF_TC_BODY(log1p_nan, tc)
244 {
245 	const double x = 0.0L / 0.0L;
246 
247 	ATF_CHECK(isnan(x) != 0);
248 	ATF_CHECK(isnan(log1p(x)) != 0);
249 }
250 
251 ATF_TC(log1p_inf_neg);
252 ATF_TC_HEAD(log1p_inf_neg, tc)
253 {
254 	atf_tc_set_md_var(tc, "descr", "Test log1p(-Inf) == NaN");
255 }
256 
257 ATF_TC_BODY(log1p_inf_neg, tc)
258 {
259 	const double x = -1.0L / 0.0L;
260 	const double y = log1p(x);
261 
262 	if (isnan(y) == 0) {
263 		atf_tc_expect_fail("PR lib/45362");
264 		atf_tc_fail("log1p(-Inf) != NaN");
265 	}
266 }
267 
268 ATF_TC(log1p_inf_pos);
269 ATF_TC_HEAD(log1p_inf_pos, tc)
270 {
271 	atf_tc_set_md_var(tc, "descr", "Test log1p(+Inf) == +Inf");
272 }
273 
274 ATF_TC_BODY(log1p_inf_pos, tc)
275 {
276 	const double x = 1.0L / 0.0L;
277 
278 	ATF_CHECK(log1p(x) == x);
279 }
280 
281 ATF_TC(log1p_one_neg);
282 ATF_TC_HEAD(log1p_one_neg, tc)
283 {
284 	atf_tc_set_md_var(tc, "descr", "Test log1p(-1.0) == -HUGE_VAL");
285 }
286 
287 ATF_TC_BODY(log1p_one_neg, tc)
288 {
289 	const double x = log1p(-1.0);
290 
291 	if (x != -HUGE_VAL) {
292 		atf_tc_expect_fail("PR lib/45362");
293 		atf_tc_fail("log1p(-1.0) != -HUGE_VAL");
294 	}
295 }
296 
297 ATF_TC(log1p_zero_neg);
298 ATF_TC_HEAD(log1p_zero_neg, tc)
299 {
300 	atf_tc_set_md_var(tc, "descr", "Test log1p(-0.0) == -0.0");
301 }
302 
303 ATF_TC_BODY(log1p_zero_neg, tc)
304 {
305 	const double x = -0.0L;
306 
307 	ATF_CHECK(log1p(x) == x);
308 }
309 
310 ATF_TC(log1p_zero_pos);
311 ATF_TC_HEAD(log1p_zero_pos, tc)
312 {
313 	atf_tc_set_md_var(tc, "descr", "Test log1p(+0.0) == +0.0");
314 }
315 
316 ATF_TC_BODY(log1p_zero_pos, tc)
317 {
318 	const double x = 0.0L;
319 
320 	ATF_CHECK(log1p(x) == x);
321 }
322 
323 /*
324  * log1pf(3)
325  */
326 ATF_TC(log1pf_nan);
327 ATF_TC_HEAD(log1pf_nan, tc)
328 {
329 	atf_tc_set_md_var(tc, "descr", "Test log1pf(NaN) == NaN");
330 }
331 
332 ATF_TC_BODY(log1pf_nan, tc)
333 {
334 	const float x = 0.0L / 0.0L;
335 
336 	ATF_CHECK(isnan(x) != 0);
337 	ATF_CHECK(isnan(log1pf(x)) != 0);
338 }
339 
340 ATF_TC(log1pf_inf_neg);
341 ATF_TC_HEAD(log1pf_inf_neg, tc)
342 {
343 	atf_tc_set_md_var(tc, "descr", "Test log1pf(-Inf) == NaN");
344 }
345 
346 ATF_TC_BODY(log1pf_inf_neg, tc)
347 {
348 	const float x = -1.0L / 0.0L;
349 	const float y = log1pf(x);
350 
351 	if (isnan(y) == 0) {
352 		atf_tc_expect_fail("PR lib/45362");
353 		atf_tc_fail("log1pf(-Inf) != NaN");
354 	}
355 }
356 
357 ATF_TC(log1pf_inf_pos);
358 ATF_TC_HEAD(log1pf_inf_pos, tc)
359 {
360 	atf_tc_set_md_var(tc, "descr", "Test log1pf(+Inf) == +Inf");
361 }
362 
363 ATF_TC_BODY(log1pf_inf_pos, tc)
364 {
365 	const float x = 1.0L / 0.0L;
366 
367 	ATF_CHECK(log1pf(x) == x);
368 }
369 
370 ATF_TC(log1pf_one_neg);
371 ATF_TC_HEAD(log1pf_one_neg, tc)
372 {
373 	atf_tc_set_md_var(tc, "descr", "Test log1pf(-1.0) == -HUGE_VALF");
374 }
375 
376 ATF_TC_BODY(log1pf_one_neg, tc)
377 {
378 	const float x = log1pf(-1.0);
379 
380 	if (x != -HUGE_VALF) {
381 		atf_tc_expect_fail("PR lib/45362");
382 		atf_tc_fail("log1pf(-1.0) != -HUGE_VALF");
383 	}
384 }
385 
386 ATF_TC(log1pf_zero_neg);
387 ATF_TC_HEAD(log1pf_zero_neg, tc)
388 {
389 	atf_tc_set_md_var(tc, "descr", "Test log1pf(-0.0) == -0.0");
390 }
391 
392 ATF_TC_BODY(log1pf_zero_neg, tc)
393 {
394 	const float x = -0.0L;
395 
396 	ATF_CHECK(log1pf(x) == x);
397 }
398 
399 ATF_TC(log1pf_zero_pos);
400 ATF_TC_HEAD(log1pf_zero_pos, tc)
401 {
402 	atf_tc_set_md_var(tc, "descr", "Test log1pf(+0.0) == +0.0");
403 }
404 
405 ATF_TC_BODY(log1pf_zero_pos, tc)
406 {
407 	const float x = 0.0L;
408 
409 	ATF_CHECK(log1pf(x) == x);
410 }
411 
412 /*
413  * log2(3)
414  */
415 ATF_TC(log2_base);
416 ATF_TC_HEAD(log2_base, tc)
417 {
418 	atf_tc_set_md_var(tc, "descr", "Test log2(2) == 1");
419 }
420 
421 ATF_TC_BODY(log2_base, tc)
422 {
423 	ATF_CHECK(log2(2.0) == 1.0);
424 }
425 
426 ATF_TC(log2_nan);
427 ATF_TC_HEAD(log2_nan, tc)
428 {
429 	atf_tc_set_md_var(tc, "descr", "Test log2(NaN) == NaN");
430 }
431 
432 ATF_TC_BODY(log2_nan, tc)
433 {
434 	const double x = 0.0L / 0.0L;
435 
436 	ATF_CHECK(isnan(x) != 0);
437 	ATF_CHECK(isnan(log2(x)) != 0);
438 }
439 
440 ATF_TC(log2_inf_neg);
441 ATF_TC_HEAD(log2_inf_neg, tc)
442 {
443 	atf_tc_set_md_var(tc, "descr", "Test log2(-Inf) == NaN");
444 }
445 
446 ATF_TC_BODY(log2_inf_neg, tc)
447 {
448 	const double x = -1.0L / 0.0L;
449 	const double y = log2(x);
450 
451 	ATF_CHECK(isnan(y) != 0);
452 }
453 
454 ATF_TC(log2_inf_pos);
455 ATF_TC_HEAD(log2_inf_pos, tc)
456 {
457 	atf_tc_set_md_var(tc, "descr", "Test log2(+Inf) == +Inf");
458 }
459 
460 ATF_TC_BODY(log2_inf_pos, tc)
461 {
462 	const double x = 1.0L / 0.0L;
463 
464 	ATF_CHECK(log2(x) == x);
465 }
466 
467 ATF_TC(log2_one_pos);
468 ATF_TC_HEAD(log2_one_pos, tc)
469 {
470 	atf_tc_set_md_var(tc, "descr", "Test log2(1.0) == +0.0");
471 }
472 
473 ATF_TC_BODY(log2_one_pos, tc)
474 {
475 	const double x = log2(1.0);
476 	const double y = 0.0L;
477 
478 	ATF_CHECK(x == y);
479 	ATF_CHECK(signbit(x) == 0);
480 	ATF_CHECK(signbit(y) == 0);
481 }
482 
483 ATF_TC(log2_zero_neg);
484 ATF_TC_HEAD(log2_zero_neg, tc)
485 {
486 	atf_tc_set_md_var(tc, "descr", "Test log2(-0.0) == -HUGE_VAL");
487 }
488 
489 ATF_TC_BODY(log2_zero_neg, tc)
490 {
491 	const double x = -0.0L;
492 
493 	ATF_CHECK(log2(x) == -HUGE_VAL);
494 }
495 
496 ATF_TC(log2_zero_pos);
497 ATF_TC_HEAD(log2_zero_pos, tc)
498 {
499 	atf_tc_set_md_var(tc, "descr", "Test log2(+0.0) == -HUGE_VAL");
500 }
501 
502 ATF_TC_BODY(log2_zero_pos, tc)
503 {
504 	const double x = 0.0L;
505 
506 	ATF_CHECK(log2(x) == -HUGE_VAL);
507 }
508 
509 /*
510  * log2f(3)
511  */
512 ATF_TC(log2f_base);
513 ATF_TC_HEAD(log2f_base, tc)
514 {
515 	atf_tc_set_md_var(tc, "descr", "Test log2f(2) == 1");
516 }
517 
518 ATF_TC_BODY(log2f_base, tc)
519 {
520 	ATF_CHECK(log2f(2.0) == 1.0);
521 }
522 
523 ATF_TC(log2f_nan);
524 ATF_TC_HEAD(log2f_nan, tc)
525 {
526 	atf_tc_set_md_var(tc, "descr", "Test log2f(NaN) == NaN");
527 }
528 
529 ATF_TC_BODY(log2f_nan, tc)
530 {
531 	const float x = 0.0L / 0.0L;
532 
533 	ATF_CHECK(isnan(x) != 0);
534 	ATF_CHECK(isnan(log2f(x)) != 0);
535 }
536 
537 ATF_TC(log2f_inf_neg);
538 ATF_TC_HEAD(log2f_inf_neg, tc)
539 {
540 	atf_tc_set_md_var(tc, "descr", "Test log2f(-Inf) == NaN");
541 }
542 
543 ATF_TC_BODY(log2f_inf_neg, tc)
544 {
545 	const float x = -1.0L / 0.0L;
546 	const float y = log2f(x);
547 
548 	ATF_CHECK(isnan(y) != 0);
549 }
550 
551 ATF_TC(log2f_inf_pos);
552 ATF_TC_HEAD(log2f_inf_pos, tc)
553 {
554 	atf_tc_set_md_var(tc, "descr", "Test log2f(+Inf) == +Inf");
555 }
556 
557 ATF_TC_BODY(log2f_inf_pos, tc)
558 {
559 	const float x = 1.0L / 0.0L;
560 
561 	ATF_CHECK(log2f(x) == x);
562 }
563 
564 ATF_TC(log2f_one_pos);
565 ATF_TC_HEAD(log2f_one_pos, tc)
566 {
567 	atf_tc_set_md_var(tc, "descr", "Test log2f(1.0) == +0.0");
568 }
569 
570 ATF_TC_BODY(log2f_one_pos, tc)
571 {
572 	const float x = log2f(1.0);
573 	const float y = 0.0L;
574 
575 	ATF_CHECK(x == y);
576 	ATF_CHECK(signbit(x) == 0);
577 	ATF_CHECK(signbit(y) == 0);
578 }
579 
580 ATF_TC(log2f_zero_neg);
581 ATF_TC_HEAD(log2f_zero_neg, tc)
582 {
583 	atf_tc_set_md_var(tc, "descr", "Test log2f(-0.0) == -HUGE_VALF");
584 }
585 
586 ATF_TC_BODY(log2f_zero_neg, tc)
587 {
588 	const float x = -0.0L;
589 
590 	ATF_CHECK(log2f(x) == -HUGE_VALF);
591 }
592 
593 ATF_TC(log2f_zero_pos);
594 ATF_TC_HEAD(log2f_zero_pos, tc)
595 {
596 	atf_tc_set_md_var(tc, "descr", "Test log2f(+0.0) == -HUGE_VALF");
597 }
598 
599 ATF_TC_BODY(log2f_zero_pos, tc)
600 {
601 	const float x = 0.0L;
602 
603 	ATF_CHECK(log2f(x) == -HUGE_VALF);
604 }
605 
606 /*
607  * log(3)
608  */
609 ATF_TC(log_base);
610 ATF_TC_HEAD(log_base, tc)
611 {
612 	atf_tc_set_md_var(tc, "descr", "Test log(e) == 1");
613 }
614 
615 ATF_TC_BODY(log_base, tc)
616 {
617 	const double eps = 1.0e-38;
618 
619 	if (fabs(log(M_E) - 1.0) > eps)
620 		atf_tc_fail_nonfatal("log(e) != 1");
621 }
622 
623 ATF_TC(log_nan);
624 ATF_TC_HEAD(log_nan, tc)
625 {
626 	atf_tc_set_md_var(tc, "descr", "Test log(NaN) == NaN");
627 }
628 
629 ATF_TC_BODY(log_nan, tc)
630 {
631 	const double x = 0.0L / 0.0L;
632 
633 	ATF_CHECK(isnan(x) != 0);
634 	ATF_CHECK(isnan(log(x)) != 0);
635 }
636 
637 ATF_TC(log_inf_neg);
638 ATF_TC_HEAD(log_inf_neg, tc)
639 {
640 	atf_tc_set_md_var(tc, "descr", "Test log(-Inf) == NaN");
641 }
642 
643 ATF_TC_BODY(log_inf_neg, tc)
644 {
645 	const double x = -1.0L / 0.0L;
646 	const double y = log(x);
647 
648 	ATF_CHECK(isnan(y) != 0);
649 }
650 
651 ATF_TC(log_inf_pos);
652 ATF_TC_HEAD(log_inf_pos, tc)
653 {
654 	atf_tc_set_md_var(tc, "descr", "Test log(+Inf) == +Inf");
655 }
656 
657 ATF_TC_BODY(log_inf_pos, tc)
658 {
659 	const double x = 1.0L / 0.0L;
660 
661 	ATF_CHECK(log(x) == x);
662 }
663 
664 ATF_TC(log_one_pos);
665 ATF_TC_HEAD(log_one_pos, tc)
666 {
667 	atf_tc_set_md_var(tc, "descr", "Test log(1.0) == +0.0");
668 }
669 
670 ATF_TC_BODY(log_one_pos, tc)
671 {
672 	const double x = log(1.0);
673 	const double y = 0.0L;
674 
675 	ATF_CHECK(x == y);
676 	ATF_CHECK(signbit(x) == 0);
677 	ATF_CHECK(signbit(y) == 0);
678 }
679 
680 ATF_TC(log_zero_neg);
681 ATF_TC_HEAD(log_zero_neg, tc)
682 {
683 	atf_tc_set_md_var(tc, "descr", "Test log(-0.0) == -HUGE_VAL");
684 }
685 
686 ATF_TC_BODY(log_zero_neg, tc)
687 {
688 	const double x = -0.0L;
689 
690 	ATF_CHECK(log(x) == -HUGE_VAL);
691 }
692 
693 ATF_TC(log_zero_pos);
694 ATF_TC_HEAD(log_zero_pos, tc)
695 {
696 	atf_tc_set_md_var(tc, "descr", "Test log(+0.0) == -HUGE_VAL");
697 }
698 
699 ATF_TC_BODY(log_zero_pos, tc)
700 {
701 	const double x = 0.0L;
702 
703 	ATF_CHECK(log(x) == -HUGE_VAL);
704 }
705 
706 /*
707  * logf(3)
708  */
709 ATF_TC(logf_base);
710 ATF_TC_HEAD(logf_base, tc)
711 {
712 	atf_tc_set_md_var(tc, "descr", "Test logf(e) == 1");
713 }
714 
715 ATF_TC_BODY(logf_base, tc)
716 {
717 	const float eps = 1.0e-7;
718 
719 	if (fabsf(logf(M_E) - 1.0f) > eps)
720 		atf_tc_fail_nonfatal("logf(e) != 1");
721 }
722 
723 ATF_TC(logf_nan);
724 ATF_TC_HEAD(logf_nan, tc)
725 {
726 	atf_tc_set_md_var(tc, "descr", "Test logf(NaN) == NaN");
727 }
728 
729 ATF_TC_BODY(logf_nan, tc)
730 {
731 	const float x = 0.0L / 0.0L;
732 
733 	ATF_CHECK(isnan(x) != 0);
734 	ATF_CHECK(isnan(logf(x)) != 0);
735 }
736 
737 ATF_TC(logf_inf_neg);
738 ATF_TC_HEAD(logf_inf_neg, tc)
739 {
740 	atf_tc_set_md_var(tc, "descr", "Test logf(-Inf) == NaN");
741 }
742 
743 ATF_TC_BODY(logf_inf_neg, tc)
744 {
745 	const float x = -1.0L / 0.0L;
746 	const float y = logf(x);
747 
748 	ATF_CHECK(isnan(y) != 0);
749 }
750 
751 ATF_TC(logf_inf_pos);
752 ATF_TC_HEAD(logf_inf_pos, tc)
753 {
754 	atf_tc_set_md_var(tc, "descr", "Test logf(+Inf) == +Inf");
755 }
756 
757 ATF_TC_BODY(logf_inf_pos, tc)
758 {
759 	const float x = 1.0L / 0.0L;
760 
761 	ATF_CHECK(logf(x) == x);
762 }
763 
764 ATF_TC(logf_one_pos);
765 ATF_TC_HEAD(logf_one_pos, tc)
766 {
767 	atf_tc_set_md_var(tc, "descr", "Test logf(1.0) == +0.0");
768 }
769 
770 ATF_TC_BODY(logf_one_pos, tc)
771 {
772 	const float x = logf(1.0);
773 	const float y = 0.0L;
774 
775 	ATF_CHECK(x == y);
776 	ATF_CHECK(signbit(x) == 0);
777 	ATF_CHECK(signbit(y) == 0);
778 }
779 
780 ATF_TC(logf_zero_neg);
781 ATF_TC_HEAD(logf_zero_neg, tc)
782 {
783 	atf_tc_set_md_var(tc, "descr", "Test logf(-0.0) == -HUGE_VALF");
784 }
785 
786 ATF_TC_BODY(logf_zero_neg, tc)
787 {
788 	const float x = -0.0L;
789 
790 	ATF_CHECK(logf(x) == -HUGE_VALF);
791 }
792 
793 ATF_TC(logf_zero_pos);
794 ATF_TC_HEAD(logf_zero_pos, tc)
795 {
796 	atf_tc_set_md_var(tc, "descr", "Test logf(+0.0) == -HUGE_VALF");
797 }
798 
799 ATF_TC_BODY(logf_zero_pos, tc)
800 {
801 	const float x = 0.0L;
802 
803 	ATF_CHECK(logf(x) == -HUGE_VALF);
804 }
805 
806 ATF_TP_ADD_TCS(tp)
807 {
808 
809 	ATF_TP_ADD_TC(tp, log10_base);
810 	ATF_TP_ADD_TC(tp, log10_nan);
811 	ATF_TP_ADD_TC(tp, log10_inf_neg);
812 	ATF_TP_ADD_TC(tp, log10_inf_pos);
813 	ATF_TP_ADD_TC(tp, log10_one_pos);
814 	ATF_TP_ADD_TC(tp, log10_zero_neg);
815 	ATF_TP_ADD_TC(tp, log10_zero_pos);
816 
817 	ATF_TP_ADD_TC(tp, log10f_base);
818 	ATF_TP_ADD_TC(tp, log10f_nan);
819 	ATF_TP_ADD_TC(tp, log10f_inf_neg);
820 	ATF_TP_ADD_TC(tp, log10f_inf_pos);
821 	ATF_TP_ADD_TC(tp, log10f_one_pos);
822 	ATF_TP_ADD_TC(tp, log10f_zero_neg);
823 	ATF_TP_ADD_TC(tp, log10f_zero_pos);
824 
825 	ATF_TP_ADD_TC(tp, log1p_nan);
826 	ATF_TP_ADD_TC(tp, log1p_inf_neg);
827 	ATF_TP_ADD_TC(tp, log1p_inf_pos);
828 	ATF_TP_ADD_TC(tp, log1p_one_neg);
829 	ATF_TP_ADD_TC(tp, log1p_zero_neg);
830 	ATF_TP_ADD_TC(tp, log1p_zero_pos);
831 
832 	ATF_TP_ADD_TC(tp, log1pf_nan);
833 	ATF_TP_ADD_TC(tp, log1pf_inf_neg);
834 	ATF_TP_ADD_TC(tp, log1pf_inf_pos);
835 	ATF_TP_ADD_TC(tp, log1pf_one_neg);
836 	ATF_TP_ADD_TC(tp, log1pf_zero_neg);
837 	ATF_TP_ADD_TC(tp, log1pf_zero_pos);
838 
839 	ATF_TP_ADD_TC(tp, log2_base);
840 	ATF_TP_ADD_TC(tp, log2_nan);
841 	ATF_TP_ADD_TC(tp, log2_inf_neg);
842 	ATF_TP_ADD_TC(tp, log2_inf_pos);
843 	ATF_TP_ADD_TC(tp, log2_one_pos);
844 	ATF_TP_ADD_TC(tp, log2_zero_neg);
845 	ATF_TP_ADD_TC(tp, log2_zero_pos);
846 
847 	ATF_TP_ADD_TC(tp, log2f_base);
848 	ATF_TP_ADD_TC(tp, log2f_nan);
849 	ATF_TP_ADD_TC(tp, log2f_inf_neg);
850 	ATF_TP_ADD_TC(tp, log2f_inf_pos);
851 	ATF_TP_ADD_TC(tp, log2f_one_pos);
852 	ATF_TP_ADD_TC(tp, log2f_zero_neg);
853 	ATF_TP_ADD_TC(tp, log2f_zero_pos);
854 
855 	ATF_TP_ADD_TC(tp, log_base);
856 	ATF_TP_ADD_TC(tp, log_nan);
857 	ATF_TP_ADD_TC(tp, log_inf_neg);
858 	ATF_TP_ADD_TC(tp, log_inf_pos);
859 	ATF_TP_ADD_TC(tp, log_one_pos);
860 	ATF_TP_ADD_TC(tp, log_zero_neg);
861 	ATF_TP_ADD_TC(tp, log_zero_pos);
862 
863 	ATF_TP_ADD_TC(tp, logf_base);
864 	ATF_TP_ADD_TC(tp, logf_nan);
865 	ATF_TP_ADD_TC(tp, logf_inf_neg);
866 	ATF_TP_ADD_TC(tp, logf_inf_pos);
867 	ATF_TP_ADD_TC(tp, logf_one_pos);
868 	ATF_TP_ADD_TC(tp, logf_zero_neg);
869 	ATF_TP_ADD_TC(tp, logf_zero_pos);
870 
871 	return atf_no_error();
872 }
873