1 /* $NetBSD: t_ceil.c,v 1.10 2014/03/03 10:39:08 martin Exp $ */
4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
31 #include <sys/cdefs.h>
32 __RCSID("$NetBSD: t_ceil.c,v 1.10 2014/03/03 10:39:08 martin Exp $");
40 #define SMALL_NUM 1.0e-38
42 #define SMALL_NUM 1.0e-40
49 ATF_TC_HEAD(ceil_basic
, tc
)
51 atf_tc_set_md_var(tc
, "descr", "A basic test of ceil(3)");
54 ATF_TC_BODY(ceil_basic
, tc
)
56 const double x
= 0.999999999999999;
57 const double y
= 0.000000000000001;
59 ATF_CHECK(fabs(ceil(x
) - 1) < SMALL_NUM
);
60 ATF_CHECK(fabs(ceil(y
) - 1) < SMALL_NUM
);
64 ATF_TC_HEAD(ceil_nan
, tc
)
66 atf_tc_set_md_var(tc
, "descr", "Test ceil(NaN) == NaN");
69 ATF_TC_BODY(ceil_nan
, tc
)
71 const double x
= 0.0L / 0.0L;
73 ATF_CHECK(isnan(ceil(x
)) != 0);
77 ATF_TC_HEAD(ceil_inf_neg
, tc
)
79 atf_tc_set_md_var(tc
, "descr", "Test ceil(-Inf) == -Inf");
82 ATF_TC_BODY(ceil_inf_neg
, tc
)
84 const double x
= -1.0L / 0.0L;
87 if (isinf(y
) == 0 || signbit(y
) == 0)
88 atf_tc_fail_nonfatal("ceil(-Inf) != -Inf");
92 ATF_TC_HEAD(ceil_inf_pos
, tc
)
94 atf_tc_set_md_var(tc
, "descr", "Test ceil(+Inf) == +Inf");
97 ATF_TC_BODY(ceil_inf_pos
, tc
)
99 const double x
= 1.0L / 0.0L;
102 if (isinf(y
) == 0 || signbit(y
) != 0)
103 atf_tc_fail_nonfatal("ceil(+Inf) != +Inf");
106 ATF_TC(ceil_zero_neg
);
107 ATF_TC_HEAD(ceil_zero_neg
, tc
)
109 atf_tc_set_md_var(tc
, "descr", "Test ceil(-0.0) == -0.0");
112 ATF_TC_BODY(ceil_zero_neg
, tc
)
114 const double x
= -0.0L;
117 if (fabs(y
) > 0.0 || signbit(y
) == 0)
118 atf_tc_fail_nonfatal("ceil(-0.0) != -0.0");
121 ATF_TC(ceil_zero_pos
);
122 ATF_TC_HEAD(ceil_zero_pos
, tc
)
124 atf_tc_set_md_var(tc
, "descr", "Test ceil(+0.0) == +0.0");
127 ATF_TC_BODY(ceil_zero_pos
, tc
)
129 const double x
= 0.0L;
132 if (fabs(y
) > 0.0 || signbit(y
) != 0)
133 atf_tc_fail_nonfatal("ceil(+0.0) != +0.0");
140 ATF_TC_HEAD(ceilf_basic
, tc
)
142 atf_tc_set_md_var(tc
, "descr", "A basic test of ceilf(3)");
145 ATF_TC_BODY(ceilf_basic
, tc
)
147 const float x
= 0.9999999;
148 const float y
= 0.0000001;
150 ATF_CHECK(fabsf(ceilf(x
) - 1) < SMALL_NUM
);
151 ATF_CHECK(fabsf(ceilf(y
) - 1) < SMALL_NUM
);
155 ATF_TC_HEAD(ceilf_nan
, tc
)
157 atf_tc_set_md_var(tc
, "descr", "Test ceilf(NaN) == NaN");
160 ATF_TC_BODY(ceilf_nan
, tc
)
162 const float x
= 0.0L / 0.0L;
164 ATF_CHECK(isnan(ceilf(x
)) != 0);
167 ATF_TC(ceilf_inf_neg
);
168 ATF_TC_HEAD(ceilf_inf_neg
, tc
)
170 atf_tc_set_md_var(tc
, "descr", "Test ceilf(-Inf) == -Inf");
173 ATF_TC_BODY(ceilf_inf_neg
, tc
)
175 const float x
= -1.0L / 0.0L;
178 if (isinf(y
) == 0 || signbit(y
) == 0)
179 atf_tc_fail_nonfatal("ceilf(-Inf) != -Inf");
182 ATF_TC(ceilf_inf_pos
);
183 ATF_TC_HEAD(ceilf_inf_pos
, tc
)
185 atf_tc_set_md_var(tc
, "descr", "Test ceilf(+Inf) == +Inf");
188 ATF_TC_BODY(ceilf_inf_pos
, tc
)
190 const float x
= 1.0L / 0.0L;
193 if (isinf(y
) == 0 || signbit(y
) != 0)
194 atf_tc_fail_nonfatal("ceilf(+Inf) != +Inf");
197 ATF_TC(ceilf_zero_neg
);
198 ATF_TC_HEAD(ceilf_zero_neg
, tc
)
200 atf_tc_set_md_var(tc
, "descr", "Test ceilf(-0.0) == -0.0");
203 ATF_TC_BODY(ceilf_zero_neg
, tc
)
205 const float x
= -0.0L;
208 if (fabsf(y
) > 0.0 || signbit(y
) == 0)
209 atf_tc_fail_nonfatal("ceilf(-0.0) != -0.0");
212 ATF_TC(ceilf_zero_pos
);
213 ATF_TC_HEAD(ceilf_zero_pos
, tc
)
215 atf_tc_set_md_var(tc
, "descr", "Test ceilf(+0.0) == +0.0");
218 ATF_TC_BODY(ceilf_zero_pos
, tc
)
220 const float x
= 0.0L;
223 if (fabsf(y
) > 0.0 || signbit(y
) != 0)
224 atf_tc_fail_nonfatal("ceilf(+0.0) != +0.0");
231 ATF_TC_HEAD(ceill_basic
, tc
)
233 atf_tc_set_md_var(tc
, "descr", "A basic test of ceill(3)");
236 ATF_TC_BODY(ceill_basic
, tc
)
238 const long double x
= 0.9999999;
239 const long double y
= 0.0000001;
241 ATF_CHECK(fabsl(ceill(x
) - 1) < SMALL_NUM
);
242 ATF_CHECK(fabsl(ceill(y
) - 1) < SMALL_NUM
);
246 ATF_TC_HEAD(ceill_nan
, tc
)
248 atf_tc_set_md_var(tc
, "descr", "Test ceill(NaN) == NaN");
251 ATF_TC_BODY(ceill_nan
, tc
)
253 const long double x
= 0.0L / 0.0L;
255 ATF_CHECK(isnan(ceill(x
)) != 0);
258 ATF_TC(ceill_inf_neg
);
259 ATF_TC_HEAD(ceill_inf_neg
, tc
)
261 atf_tc_set_md_var(tc
, "descr", "Test ceill(-Inf) == -Inf");
264 ATF_TC_BODY(ceill_inf_neg
, tc
)
266 const long double x
= -1.0L / 0.0L;
267 long double y
= ceill(x
);
269 if (isinf(y
) == 0 || signbit(y
) == 0)
270 atf_tc_fail_nonfatal("ceill(-Inf) != -Inf");
273 ATF_TC(ceill_inf_pos
);
274 ATF_TC_HEAD(ceill_inf_pos
, tc
)
276 atf_tc_set_md_var(tc
, "descr", "Test ceill(+Inf) == +Inf");
279 ATF_TC_BODY(ceill_inf_pos
, tc
)
281 const long double x
= 1.0L / 0.0L;
282 long double y
= ceill(x
);
284 if (isinf(y
) == 0 || signbit(y
) != 0)
285 atf_tc_fail_nonfatal("ceill(+Inf) != +Inf");
288 ATF_TC(ceill_zero_neg
);
289 ATF_TC_HEAD(ceill_zero_neg
, tc
)
291 atf_tc_set_md_var(tc
, "descr", "Test ceill(-0.0) == -0.0");
294 ATF_TC_BODY(ceill_zero_neg
, tc
)
296 const long double x
= -0.0L;
297 long double y
= ceill(x
);
299 if (fabsl(y
) > 0.0 || signbit(y
) == 0)
300 atf_tc_fail_nonfatal("ceill(-0.0) != -0.0");
303 ATF_TC(ceill_zero_pos
);
304 ATF_TC_HEAD(ceill_zero_pos
, tc
)
306 atf_tc_set_md_var(tc
, "descr", "Test ceill(+0.0) == +0.0");
309 ATF_TC_BODY(ceill_zero_pos
, tc
)
311 const long double x
= 0.0L;
312 long double y
= ceill(x
);
314 if (fabsl(y
) > 0.0 || signbit(y
) != 0)
315 atf_tc_fail_nonfatal("ceill(+0.0) != +0.0");
322 ATF_TC_HEAD(floor_basic
, tc
)
324 atf_tc_set_md_var(tc
, "descr", "A basic test of floor(3)");
327 ATF_TC_BODY(floor_basic
, tc
)
329 const double x
= 0.999999999999999;
330 const double y
= 0.000000000000001;
332 ATF_CHECK(floor(x
) < SMALL_NUM
);
333 ATF_CHECK(floor(y
) < SMALL_NUM
);
337 ATF_TC_HEAD(floor_nan
, tc
)
339 atf_tc_set_md_var(tc
, "descr", "Test floor(NaN) == NaN");
342 ATF_TC_BODY(floor_nan
, tc
)
344 const double x
= 0.0L / 0.0L;
346 ATF_CHECK(isnan(floor(x
)) != 0);
349 ATF_TC(floor_inf_neg
);
350 ATF_TC_HEAD(floor_inf_neg
, tc
)
352 atf_tc_set_md_var(tc
, "descr", "Test floor(-Inf) == -Inf");
355 ATF_TC_BODY(floor_inf_neg
, tc
)
357 const double x
= -1.0L / 0.0L;
360 if (isinf(y
) == 0 || signbit(y
) == 0)
361 atf_tc_fail_nonfatal("floor(-Inf) != -Inf");
364 ATF_TC(floor_inf_pos
);
365 ATF_TC_HEAD(floor_inf_pos
, tc
)
367 atf_tc_set_md_var(tc
, "descr", "Test floor(+Inf) == +Inf");
370 ATF_TC_BODY(floor_inf_pos
, tc
)
372 const double x
= 1.0L / 0.0L;
375 if (isinf(y
) == 0 || signbit(y
) != 0)
376 atf_tc_fail_nonfatal("floor(+Inf) != +Inf");
379 ATF_TC(floor_zero_neg
);
380 ATF_TC_HEAD(floor_zero_neg
, tc
)
382 atf_tc_set_md_var(tc
, "descr", "Test floor(-0.0) == -0.0");
385 ATF_TC_BODY(floor_zero_neg
, tc
)
387 const double x
= -0.0L;
390 if (fabs(y
) > 0.0 || signbit(y
) == 0)
391 atf_tc_fail_nonfatal("floor(-0.0) != -0.0");
394 ATF_TC(floor_zero_pos
);
395 ATF_TC_HEAD(floor_zero_pos
, tc
)
397 atf_tc_set_md_var(tc
, "descr", "Test floor(+0.0) == +0.0");
400 ATF_TC_BODY(floor_zero_pos
, tc
)
402 const double x
= 0.0L;
405 if (fabs(y
) > 0.0 || signbit(y
) != 0)
406 atf_tc_fail_nonfatal("floor(+0.0) != +0.0");
412 ATF_TC(floorf_basic
);
413 ATF_TC_HEAD(floorf_basic
, tc
)
415 atf_tc_set_md_var(tc
, "descr", "A basic test of floorf(3)");
418 ATF_TC_BODY(floorf_basic
, tc
)
420 const float x
= 0.9999999;
421 const float y
= 0.0000001;
423 ATF_CHECK(floorf(x
) < SMALL_NUM
);
424 ATF_CHECK(floorf(y
) < SMALL_NUM
);
428 ATF_TC_HEAD(floorf_nan
, tc
)
430 atf_tc_set_md_var(tc
, "descr", "Test floorf(NaN) == NaN");
433 ATF_TC_BODY(floorf_nan
, tc
)
435 const float x
= 0.0L / 0.0L;
437 ATF_CHECK(isnan(floorf(x
)) != 0);
440 ATF_TC(floorf_inf_neg
);
441 ATF_TC_HEAD(floorf_inf_neg
, tc
)
443 atf_tc_set_md_var(tc
, "descr", "Test floorf(-Inf) == -Inf");
446 ATF_TC_BODY(floorf_inf_neg
, tc
)
448 const float x
= -1.0L / 0.0L;
451 if (isinf(y
) == 0 || signbit(y
) == 0)
452 atf_tc_fail_nonfatal("floorf(-Inf) != -Inf");
455 ATF_TC(floorf_inf_pos
);
456 ATF_TC_HEAD(floorf_inf_pos
, tc
)
458 atf_tc_set_md_var(tc
, "descr", "Test floorf(+Inf) == +Inf");
461 ATF_TC_BODY(floorf_inf_pos
, tc
)
463 const float x
= 1.0L / 0.0L;
466 if (isinf(y
) == 0 || signbit(y
) != 0)
467 atf_tc_fail_nonfatal("floorf(+Inf) != +Inf");
470 ATF_TC(floorf_zero_neg
);
471 ATF_TC_HEAD(floorf_zero_neg
, tc
)
473 atf_tc_set_md_var(tc
, "descr", "Test floorf(-0.0) == -0.0");
476 ATF_TC_BODY(floorf_zero_neg
, tc
)
478 const float x
= -0.0L;
481 if (fabsf(y
) > 0.0 || signbit(y
) == 0)
482 atf_tc_fail_nonfatal("floorf(-0.0) != -0.0");
485 ATF_TC(floorf_zero_pos
);
486 ATF_TC_HEAD(floorf_zero_pos
, tc
)
488 atf_tc_set_md_var(tc
, "descr", "Test floorf(+0.0) == +0.0");
491 ATF_TC_BODY(floorf_zero_pos
, tc
)
493 const float x
= 0.0L;
496 if (fabsf(y
) > 0.0 || signbit(y
) != 0)
497 atf_tc_fail_nonfatal("floorf(+0.0) != +0.0");
503 ATF_TC(floorl_basic
);
504 ATF_TC_HEAD(floorl_basic
, tc
)
506 atf_tc_set_md_var(tc
, "descr", "A basic test of floorl(3)");
509 ATF_TC_BODY(floorl_basic
, tc
)
511 const long double x
= 0.9999999;
512 const long double y
= 0.0000001;
514 ATF_CHECK(floorl(x
) < SMALL_NUM
);
515 ATF_CHECK(floorl(y
) < SMALL_NUM
);
519 ATF_TC_HEAD(floorl_nan
, tc
)
521 atf_tc_set_md_var(tc
, "descr", "Test floorl(NaN) == NaN");
524 ATF_TC_BODY(floorl_nan
, tc
)
526 const long double x
= 0.0L / 0.0L;
528 ATF_CHECK(isnan(floorl(x
)) != 0);
531 ATF_TC(floorl_inf_neg
);
532 ATF_TC_HEAD(floorl_inf_neg
, tc
)
534 atf_tc_set_md_var(tc
, "descr", "Test floorl(-Inf) == -Inf");
537 ATF_TC_BODY(floorl_inf_neg
, tc
)
539 const long double x
= -1.0L / 0.0L;
540 long double y
= floorl(x
);
542 if (isinf(y
) == 0 || signbit(y
) == 0)
543 atf_tc_fail_nonfatal("floorl(-Inf) != -Inf");
546 ATF_TC(floorl_inf_pos
);
547 ATF_TC_HEAD(floorl_inf_pos
, tc
)
549 atf_tc_set_md_var(tc
, "descr", "Test floorl(+Inf) == +Inf");
552 ATF_TC_BODY(floorl_inf_pos
, tc
)
554 const long double x
= 1.0L / 0.0L;
555 long double y
= floorl(x
);
557 if (isinf(y
) == 0 || signbit(y
) != 0)
558 atf_tc_fail_nonfatal("floorl(+Inf) != +Inf");
561 ATF_TC(floorl_zero_neg
);
562 ATF_TC_HEAD(floorl_zero_neg
, tc
)
564 atf_tc_set_md_var(tc
, "descr", "Test floorl(-0.0) == -0.0");
567 ATF_TC_BODY(floorl_zero_neg
, tc
)
569 const long double x
= -0.0L;
570 long double y
= floorl(x
);
572 if (fabsl(y
) > 0.0 || signbit(y
) == 0)
573 atf_tc_fail_nonfatal("floorl(-0.0) != -0.0");
576 ATF_TC(floorl_zero_pos
);
577 ATF_TC_HEAD(floorl_zero_pos
, tc
)
579 atf_tc_set_md_var(tc
, "descr", "Test floorl(+0.0) == +0.0");
582 ATF_TC_BODY(floorl_zero_pos
, tc
)
584 const long double x
= 0.0L;
585 long double y
= floorl(x
);
587 if (fabsl(y
) > 0.0 || signbit(y
) != 0)
588 atf_tc_fail_nonfatal("floorl(+0.0) != +0.0");
595 ATF_TC_HEAD(trunc_basic
, tc
)
597 atf_tc_set_md_var(tc
, "descr", "A basic test of trunc(3)");
600 ATF_TC_BODY(trunc_basic
, tc
)
602 const double x
= 0.999999999999999;
603 const double y
= 0.000000000000001;
605 ATF_CHECK(trunc(x
) < SMALL_NUM
);
606 ATF_CHECK(trunc(y
) < SMALL_NUM
);
610 ATF_TC_HEAD(trunc_nan
, tc
)
612 atf_tc_set_md_var(tc
, "descr", "Test trunc(NaN) == NaN");
615 ATF_TC_BODY(trunc_nan
, tc
)
617 const double x
= 0.0L / 0.0L;
619 ATF_CHECK(isnan(trunc(x
)) != 0);
622 ATF_TC(trunc_inf_neg
);
623 ATF_TC_HEAD(trunc_inf_neg
, tc
)
625 atf_tc_set_md_var(tc
, "descr", "Test trunc(-Inf) == -Inf");
628 ATF_TC_BODY(trunc_inf_neg
, tc
)
630 const double x
= -1.0L / 0.0L;
633 if (isinf(y
) == 0 || signbit(y
) == 0)
634 atf_tc_fail_nonfatal("trunc(-Inf) != -Inf");
637 ATF_TC(trunc_inf_pos
);
638 ATF_TC_HEAD(trunc_inf_pos
, tc
)
640 atf_tc_set_md_var(tc
, "descr", "Test trunc(+Inf) == +Inf");
643 ATF_TC_BODY(trunc_inf_pos
, tc
)
645 const double x
= 1.0L / 0.0L;
648 if (isinf(y
) == 0 || signbit(y
) != 0)
649 atf_tc_fail_nonfatal("trunc(+Inf) != +Inf");
652 ATF_TC(trunc_zero_neg
);
653 ATF_TC_HEAD(trunc_zero_neg
, tc
)
655 atf_tc_set_md_var(tc
, "descr", "Test trunc(-0.0) == -0.0");
658 ATF_TC_BODY(trunc_zero_neg
, tc
)
660 const double x
= -0.0L;
663 if (fabs(y
) > 0.0 || signbit(y
) == 0)
664 atf_tc_fail_nonfatal("trunc(-0.0) != -0.0");
667 ATF_TC(trunc_zero_pos
);
668 ATF_TC_HEAD(trunc_zero_pos
, tc
)
670 atf_tc_set_md_var(tc
, "descr", "Test trunc(+0.0) == +0.0");
673 ATF_TC_BODY(trunc_zero_pos
, tc
)
675 const double x
= 0.0L;
678 if (fabs(y
) > 0.0 || signbit(y
) != 0)
679 atf_tc_fail_nonfatal("trunc(+0.0) != +0.0");
685 ATF_TC(truncf_basic
);
686 ATF_TC_HEAD(truncf_basic
, tc
)
688 atf_tc_set_md_var(tc
, "descr", "A basic test of truncf(3)");
691 ATF_TC_BODY(truncf_basic
, tc
)
693 const float x
= 0.9999999;
694 const float y
= 0.0000001;
696 ATF_CHECK(truncf(x
) < SMALL_NUM
);
697 ATF_CHECK(truncf(y
) < SMALL_NUM
);
701 ATF_TC_HEAD(truncf_nan
, tc
)
703 atf_tc_set_md_var(tc
, "descr", "Test truncf(NaN) == NaN");
706 ATF_TC_BODY(truncf_nan
, tc
)
708 const float x
= 0.0L / 0.0L;
710 ATF_CHECK(isnan(truncf(x
)) != 0);
713 ATF_TC(truncf_inf_neg
);
714 ATF_TC_HEAD(truncf_inf_neg
, tc
)
716 atf_tc_set_md_var(tc
, "descr", "Test truncf(-Inf) == -Inf");
719 ATF_TC_BODY(truncf_inf_neg
, tc
)
721 const float x
= -1.0L / 0.0L;
724 if (isinf(y
) == 0 || signbit(y
) == 0)
725 atf_tc_fail_nonfatal("truncf(-Inf) != -Inf");
728 ATF_TC(truncf_inf_pos
);
729 ATF_TC_HEAD(truncf_inf_pos
, tc
)
731 atf_tc_set_md_var(tc
, "descr", "Test truncf(+Inf) == +Inf");
734 ATF_TC_BODY(truncf_inf_pos
, tc
)
736 const float x
= 1.0L / 0.0L;
739 if (isinf(y
) == 0 || signbit(y
) != 0)
740 atf_tc_fail_nonfatal("truncf(+Inf) != +Inf");
743 ATF_TC(truncf_zero_neg
);
744 ATF_TC_HEAD(truncf_zero_neg
, tc
)
746 atf_tc_set_md_var(tc
, "descr", "Test truncf(-0.0) == -0.0");
749 ATF_TC_BODY(truncf_zero_neg
, tc
)
751 const float x
= -0.0L;
754 if (fabsf(y
) > 0.0 || signbit(y
) == 0)
755 atf_tc_fail_nonfatal("truncf(-0.0) != -0.0");
758 ATF_TC(truncf_zero_pos
);
759 ATF_TC_HEAD(truncf_zero_pos
, tc
)
761 atf_tc_set_md_var(tc
, "descr", "Test truncf(+0.0) == +0.0");
764 ATF_TC_BODY(truncf_zero_pos
, tc
)
766 const float x
= 0.0L;
769 if (fabsf(y
) > 0.0 || signbit(y
) != 0)
770 atf_tc_fail_nonfatal("truncf(+0.0) != +0.0");
776 ATF_TC(truncl_basic
);
777 ATF_TC_HEAD(truncl_basic
, tc
)
779 atf_tc_set_md_var(tc
, "descr", "A basic test of truncl(3)");
782 ATF_TC_BODY(truncl_basic
, tc
)
784 const long double x
= 0.9999999;
785 const long double y
= 0.0000001;
787 ATF_CHECK(truncl(x
) < SMALL_NUM
);
788 ATF_CHECK(truncl(y
) < SMALL_NUM
);
792 ATF_TC_HEAD(truncl_nan
, tc
)
794 atf_tc_set_md_var(tc
, "descr", "Test truncl(NaN) == NaN");
797 ATF_TC_BODY(truncl_nan
, tc
)
799 const long double x
= 0.0L / 0.0L;
801 ATF_CHECK(isnan(truncl(x
)) != 0);
804 ATF_TC(truncl_inf_neg
);
805 ATF_TC_HEAD(truncl_inf_neg
, tc
)
807 atf_tc_set_md_var(tc
, "descr", "Test truncl(-Inf) == -Inf");
810 ATF_TC_BODY(truncl_inf_neg
, tc
)
812 const long double x
= -1.0L / 0.0L;
813 long double y
= truncl(x
);
815 if (isinf(y
) == 0 || signbit(y
) == 0)
816 atf_tc_fail_nonfatal("truncl(-Inf) != -Inf");
819 ATF_TC(truncl_inf_pos
);
820 ATF_TC_HEAD(truncl_inf_pos
, tc
)
822 atf_tc_set_md_var(tc
, "descr", "Test truncl(+Inf) == +Inf");
825 ATF_TC_BODY(truncl_inf_pos
, tc
)
827 const long double x
= 1.0L / 0.0L;
828 long double y
= truncl(x
);
830 if (isinf(y
) == 0 || signbit(y
) != 0)
831 atf_tc_fail_nonfatal("truncl(+Inf) != +Inf");
834 ATF_TC(truncl_zero_neg
);
835 ATF_TC_HEAD(truncl_zero_neg
, tc
)
837 atf_tc_set_md_var(tc
, "descr", "Test truncl(-0.0) == -0.0");
840 ATF_TC_BODY(truncl_zero_neg
, tc
)
842 const long double x
= -0.0L;
843 long double y
= truncl(x
);
845 if (fabsl(y
) > 0.0 || signbit(y
) == 0)
846 atf_tc_fail_nonfatal("truncl(-0.0) != -0.0");
849 ATF_TC(truncl_zero_pos
);
850 ATF_TC_HEAD(truncl_zero_pos
, tc
)
852 atf_tc_set_md_var(tc
, "descr", "Test truncl(+0.0) == +0.0");
855 ATF_TC_BODY(truncl_zero_pos
, tc
)
857 const long double x
= 0.0L;
858 long double y
= truncl(x
);
860 if (fabsl(y
) > 0.0 || signbit(y
) != 0)
861 atf_tc_fail_nonfatal("truncl(+0.0) != +0.0");
867 ATF_TP_ADD_TC(tp
, ceil_basic
);
868 ATF_TP_ADD_TC(tp
, ceil_nan
);
869 ATF_TP_ADD_TC(tp
, ceil_inf_neg
);
870 ATF_TP_ADD_TC(tp
, ceil_inf_pos
);
871 ATF_TP_ADD_TC(tp
, ceil_zero_neg
);
872 ATF_TP_ADD_TC(tp
, ceil_zero_pos
);
874 ATF_TP_ADD_TC(tp
, ceilf_basic
);
875 ATF_TP_ADD_TC(tp
, ceilf_nan
);
876 ATF_TP_ADD_TC(tp
, ceilf_inf_neg
);
877 ATF_TP_ADD_TC(tp
, ceilf_inf_pos
);
878 ATF_TP_ADD_TC(tp
, ceilf_zero_neg
);
879 ATF_TP_ADD_TC(tp
, ceilf_zero_pos
);
881 ATF_TP_ADD_TC(tp
, ceill_basic
);
882 ATF_TP_ADD_TC(tp
, ceill_nan
);
883 ATF_TP_ADD_TC(tp
, ceill_inf_neg
);
884 ATF_TP_ADD_TC(tp
, ceill_inf_pos
);
885 ATF_TP_ADD_TC(tp
, ceill_zero_neg
);
886 ATF_TP_ADD_TC(tp
, ceill_zero_pos
);
888 ATF_TP_ADD_TC(tp
, floor_basic
);
889 ATF_TP_ADD_TC(tp
, floor_nan
);
890 ATF_TP_ADD_TC(tp
, floor_inf_neg
);
891 ATF_TP_ADD_TC(tp
, floor_inf_pos
);
892 ATF_TP_ADD_TC(tp
, floor_zero_neg
);
893 ATF_TP_ADD_TC(tp
, floor_zero_pos
);
895 ATF_TP_ADD_TC(tp
, floorf_basic
);
896 ATF_TP_ADD_TC(tp
, floorf_nan
);
897 ATF_TP_ADD_TC(tp
, floorf_inf_neg
);
898 ATF_TP_ADD_TC(tp
, floorf_inf_pos
);
899 ATF_TP_ADD_TC(tp
, floorf_zero_neg
);
900 ATF_TP_ADD_TC(tp
, floorf_zero_pos
);
902 ATF_TP_ADD_TC(tp
, floorl_basic
);
903 ATF_TP_ADD_TC(tp
, floorl_nan
);
904 ATF_TP_ADD_TC(tp
, floorl_inf_neg
);
905 ATF_TP_ADD_TC(tp
, floorl_inf_pos
);
906 ATF_TP_ADD_TC(tp
, floorl_zero_neg
);
907 ATF_TP_ADD_TC(tp
, floorl_zero_pos
);
909 ATF_TP_ADD_TC(tp
, trunc_basic
);
910 ATF_TP_ADD_TC(tp
, trunc_nan
);
911 ATF_TP_ADD_TC(tp
, trunc_inf_neg
);
912 ATF_TP_ADD_TC(tp
, trunc_inf_pos
);
913 ATF_TP_ADD_TC(tp
, trunc_zero_neg
);
914 ATF_TP_ADD_TC(tp
, trunc_zero_pos
);
916 ATF_TP_ADD_TC(tp
, truncf_basic
);
917 ATF_TP_ADD_TC(tp
, truncf_nan
);
918 ATF_TP_ADD_TC(tp
, truncf_inf_neg
);
919 ATF_TP_ADD_TC(tp
, truncf_inf_pos
);
920 ATF_TP_ADD_TC(tp
, truncf_zero_neg
);
921 ATF_TP_ADD_TC(tp
, truncf_zero_pos
);
923 ATF_TP_ADD_TC(tp
, truncl_basic
);
924 ATF_TP_ADD_TC(tp
, truncl_nan
);
925 ATF_TP_ADD_TC(tp
, truncl_inf_neg
);
926 ATF_TP_ADD_TC(tp
, truncl_inf_pos
);
927 ATF_TP_ADD_TC(tp
, truncl_zero_neg
);
928 ATF_TP_ADD_TC(tp
, truncl_zero_pos
);
930 return atf_no_error();