1 /* $NetBSD: t_ceil.c,v 1.9 2013/11/13 12:58:11 joerg 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.9 2013/11/13 12:58:11 joerg 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
)
72 const double x
= 0.0L / 0.0L;
74 ATF_CHECK(isnan(ceil(x
)) != 0);
79 ATF_TC_HEAD(ceil_inf_neg
, tc
)
81 atf_tc_set_md_var(tc
, "descr", "Test ceil(-Inf) == -Inf");
84 ATF_TC_BODY(ceil_inf_neg
, tc
)
87 const double x
= -1.0L / 0.0L;
90 if (isinf(y
) == 0 || signbit(y
) == 0)
91 atf_tc_fail_nonfatal("ceil(-Inf) != -Inf");
96 ATF_TC_HEAD(ceil_inf_pos
, tc
)
98 atf_tc_set_md_var(tc
, "descr", "Test ceil(+Inf) == +Inf");
101 ATF_TC_BODY(ceil_inf_pos
, tc
)
104 const double x
= 1.0L / 0.0L;
107 if (isinf(y
) == 0 || signbit(y
) != 0)
108 atf_tc_fail_nonfatal("ceil(+Inf) != +Inf");
112 ATF_TC(ceil_zero_neg
);
113 ATF_TC_HEAD(ceil_zero_neg
, tc
)
115 atf_tc_set_md_var(tc
, "descr", "Test ceil(-0.0) == -0.0");
118 ATF_TC_BODY(ceil_zero_neg
, tc
)
121 const double x
= -0.0L;
124 if (fabs(y
) > 0.0 || signbit(y
) == 0)
125 atf_tc_fail_nonfatal("ceil(-0.0) != -0.0");
129 ATF_TC(ceil_zero_pos
);
130 ATF_TC_HEAD(ceil_zero_pos
, tc
)
132 atf_tc_set_md_var(tc
, "descr", "Test ceil(+0.0) == +0.0");
135 ATF_TC_BODY(ceil_zero_pos
, tc
)
138 const double x
= 0.0L;
141 if (fabs(y
) > 0.0 || signbit(y
) != 0)
142 atf_tc_fail_nonfatal("ceil(+0.0) != +0.0");
150 ATF_TC_HEAD(ceilf_basic
, tc
)
152 atf_tc_set_md_var(tc
, "descr", "A basic test of ceilf(3)");
155 ATF_TC_BODY(ceilf_basic
, tc
)
157 const float x
= 0.9999999;
158 const float y
= 0.0000001;
160 ATF_CHECK(fabsf(ceilf(x
) - 1) < SMALL_NUM
);
161 ATF_CHECK(fabsf(ceilf(y
) - 1) < SMALL_NUM
);
165 ATF_TC_HEAD(ceilf_nan
, tc
)
167 atf_tc_set_md_var(tc
, "descr", "Test ceilf(NaN) == NaN");
170 ATF_TC_BODY(ceilf_nan
, tc
)
173 const float x
= 0.0L / 0.0L;
175 ATF_CHECK(isnan(ceilf(x
)) != 0);
179 ATF_TC(ceilf_inf_neg
);
180 ATF_TC_HEAD(ceilf_inf_neg
, tc
)
182 atf_tc_set_md_var(tc
, "descr", "Test ceilf(-Inf) == -Inf");
185 ATF_TC_BODY(ceilf_inf_neg
, tc
)
188 const float x
= -1.0L / 0.0L;
191 if (isinf(y
) == 0 || signbit(y
) == 0)
192 atf_tc_fail_nonfatal("ceilf(-Inf) != -Inf");
196 ATF_TC(ceilf_inf_pos
);
197 ATF_TC_HEAD(ceilf_inf_pos
, tc
)
199 atf_tc_set_md_var(tc
, "descr", "Test ceilf(+Inf) == +Inf");
202 ATF_TC_BODY(ceilf_inf_pos
, tc
)
205 const float x
= 1.0L / 0.0L;
208 if (isinf(y
) == 0 || signbit(y
) != 0)
209 atf_tc_fail_nonfatal("ceilf(+Inf) != +Inf");
213 ATF_TC(ceilf_zero_neg
);
214 ATF_TC_HEAD(ceilf_zero_neg
, tc
)
216 atf_tc_set_md_var(tc
, "descr", "Test ceilf(-0.0) == -0.0");
219 ATF_TC_BODY(ceilf_zero_neg
, tc
)
222 const float x
= -0.0L;
225 if (fabsf(y
) > 0.0 || signbit(y
) == 0)
226 atf_tc_fail_nonfatal("ceilf(-0.0) != -0.0");
230 ATF_TC(ceilf_zero_pos
);
231 ATF_TC_HEAD(ceilf_zero_pos
, tc
)
233 atf_tc_set_md_var(tc
, "descr", "Test ceilf(+0.0) == +0.0");
236 ATF_TC_BODY(ceilf_zero_pos
, tc
)
239 const float x
= 0.0L;
242 if (fabsf(y
) > 0.0 || signbit(y
) != 0)
243 atf_tc_fail_nonfatal("ceilf(+0.0) != +0.0");
251 ATF_TC_HEAD(ceill_basic
, tc
)
253 atf_tc_set_md_var(tc
, "descr", "A basic test of ceill(3)");
256 ATF_TC_BODY(ceill_basic
, tc
)
258 const long double x
= 0.9999999;
259 const long double y
= 0.0000001;
261 ATF_CHECK(fabsl(ceill(x
) - 1) < SMALL_NUM
);
262 ATF_CHECK(fabsl(ceill(y
) - 1) < SMALL_NUM
);
266 ATF_TC_HEAD(ceill_nan
, tc
)
268 atf_tc_set_md_var(tc
, "descr", "Test ceill(NaN) == NaN");
271 ATF_TC_BODY(ceill_nan
, tc
)
274 const long double x
= 0.0L / 0.0L;
276 ATF_CHECK(isnan(ceill(x
)) != 0);
280 ATF_TC(ceill_inf_neg
);
281 ATF_TC_HEAD(ceill_inf_neg
, tc
)
283 atf_tc_set_md_var(tc
, "descr", "Test ceill(-Inf) == -Inf");
286 ATF_TC_BODY(ceill_inf_neg
, tc
)
289 const long double x
= -1.0L / 0.0L;
290 long double y
= ceill(x
);
292 if (isinf(y
) == 0 || signbit(y
) == 0)
293 atf_tc_fail_nonfatal("ceill(-Inf) != -Inf");
297 ATF_TC(ceill_inf_pos
);
298 ATF_TC_HEAD(ceill_inf_pos
, tc
)
300 atf_tc_set_md_var(tc
, "descr", "Test ceill(+Inf) == +Inf");
303 ATF_TC_BODY(ceill_inf_pos
, tc
)
306 const long double x
= 1.0L / 0.0L;
307 long double y
= ceill(x
);
309 if (isinf(y
) == 0 || signbit(y
) != 0)
310 atf_tc_fail_nonfatal("ceill(+Inf) != +Inf");
314 ATF_TC(ceill_zero_neg
);
315 ATF_TC_HEAD(ceill_zero_neg
, tc
)
317 atf_tc_set_md_var(tc
, "descr", "Test ceill(-0.0) == -0.0");
320 ATF_TC_BODY(ceill_zero_neg
, tc
)
323 const long double x
= -0.0L;
324 long double y
= ceill(x
);
326 if (fabsl(y
) > 0.0 || signbit(y
) == 0)
327 atf_tc_fail_nonfatal("ceill(-0.0) != -0.0");
331 ATF_TC(ceill_zero_pos
);
332 ATF_TC_HEAD(ceill_zero_pos
, tc
)
334 atf_tc_set_md_var(tc
, "descr", "Test ceill(+0.0) == +0.0");
337 ATF_TC_BODY(ceill_zero_pos
, tc
)
340 const long double x
= 0.0L;
341 long double y
= ceill(x
);
343 if (fabsl(y
) > 0.0 || signbit(y
) != 0)
344 atf_tc_fail_nonfatal("ceill(+0.0) != +0.0");
352 ATF_TC_HEAD(floor_basic
, tc
)
354 atf_tc_set_md_var(tc
, "descr", "A basic test of floor(3)");
357 ATF_TC_BODY(floor_basic
, tc
)
359 const double x
= 0.999999999999999;
360 const double y
= 0.000000000000001;
362 ATF_CHECK(floor(x
) < SMALL_NUM
);
363 ATF_CHECK(floor(y
) < SMALL_NUM
);
367 ATF_TC_HEAD(floor_nan
, tc
)
369 atf_tc_set_md_var(tc
, "descr", "Test floor(NaN) == NaN");
372 ATF_TC_BODY(floor_nan
, tc
)
375 const double x
= 0.0L / 0.0L;
377 ATF_CHECK(isnan(floor(x
)) != 0);
381 ATF_TC(floor_inf_neg
);
382 ATF_TC_HEAD(floor_inf_neg
, tc
)
384 atf_tc_set_md_var(tc
, "descr", "Test floor(-Inf) == -Inf");
387 ATF_TC_BODY(floor_inf_neg
, tc
)
390 const double x
= -1.0L / 0.0L;
393 if (isinf(y
) == 0 || signbit(y
) == 0)
394 atf_tc_fail_nonfatal("floor(-Inf) != -Inf");
398 ATF_TC(floor_inf_pos
);
399 ATF_TC_HEAD(floor_inf_pos
, tc
)
401 atf_tc_set_md_var(tc
, "descr", "Test floor(+Inf) == +Inf");
404 ATF_TC_BODY(floor_inf_pos
, tc
)
407 const double x
= 1.0L / 0.0L;
410 if (isinf(y
) == 0 || signbit(y
) != 0)
411 atf_tc_fail_nonfatal("floor(+Inf) != +Inf");
415 ATF_TC(floor_zero_neg
);
416 ATF_TC_HEAD(floor_zero_neg
, tc
)
418 atf_tc_set_md_var(tc
, "descr", "Test floor(-0.0) == -0.0");
421 ATF_TC_BODY(floor_zero_neg
, tc
)
424 const double x
= -0.0L;
427 if (fabs(y
) > 0.0 || signbit(y
) == 0)
428 atf_tc_fail_nonfatal("floor(-0.0) != -0.0");
432 ATF_TC(floor_zero_pos
);
433 ATF_TC_HEAD(floor_zero_pos
, tc
)
435 atf_tc_set_md_var(tc
, "descr", "Test floor(+0.0) == +0.0");
438 ATF_TC_BODY(floor_zero_pos
, tc
)
441 const double x
= 0.0L;
444 if (fabs(y
) > 0.0 || signbit(y
) != 0)
445 atf_tc_fail_nonfatal("floor(+0.0) != +0.0");
452 ATF_TC(floorf_basic
);
453 ATF_TC_HEAD(floorf_basic
, tc
)
455 atf_tc_set_md_var(tc
, "descr", "A basic test of floorf(3)");
458 ATF_TC_BODY(floorf_basic
, tc
)
460 const float x
= 0.9999999;
461 const float y
= 0.0000001;
463 ATF_CHECK(floorf(x
) < SMALL_NUM
);
464 ATF_CHECK(floorf(y
) < SMALL_NUM
);
468 ATF_TC_HEAD(floorf_nan
, tc
)
470 atf_tc_set_md_var(tc
, "descr", "Test floorf(NaN) == NaN");
473 ATF_TC_BODY(floorf_nan
, tc
)
476 const float x
= 0.0L / 0.0L;
478 ATF_CHECK(isnan(floorf(x
)) != 0);
482 ATF_TC(floorf_inf_neg
);
483 ATF_TC_HEAD(floorf_inf_neg
, tc
)
485 atf_tc_set_md_var(tc
, "descr", "Test floorf(-Inf) == -Inf");
488 ATF_TC_BODY(floorf_inf_neg
, tc
)
491 const float x
= -1.0L / 0.0L;
494 if (isinf(y
) == 0 || signbit(y
) == 0)
495 atf_tc_fail_nonfatal("floorf(-Inf) != -Inf");
499 ATF_TC(floorf_inf_pos
);
500 ATF_TC_HEAD(floorf_inf_pos
, tc
)
502 atf_tc_set_md_var(tc
, "descr", "Test floorf(+Inf) == +Inf");
505 ATF_TC_BODY(floorf_inf_pos
, tc
)
508 const float x
= 1.0L / 0.0L;
511 if (isinf(y
) == 0 || signbit(y
) != 0)
512 atf_tc_fail_nonfatal("floorf(+Inf) != +Inf");
516 ATF_TC(floorf_zero_neg
);
517 ATF_TC_HEAD(floorf_zero_neg
, tc
)
519 atf_tc_set_md_var(tc
, "descr", "Test floorf(-0.0) == -0.0");
522 ATF_TC_BODY(floorf_zero_neg
, tc
)
525 const float x
= -0.0L;
528 if (fabsf(y
) > 0.0 || signbit(y
) == 0)
529 atf_tc_fail_nonfatal("floorf(-0.0) != -0.0");
533 ATF_TC(floorf_zero_pos
);
534 ATF_TC_HEAD(floorf_zero_pos
, tc
)
536 atf_tc_set_md_var(tc
, "descr", "Test floorf(+0.0) == +0.0");
539 ATF_TC_BODY(floorf_zero_pos
, tc
)
542 const float x
= 0.0L;
545 if (fabsf(y
) > 0.0 || signbit(y
) != 0)
546 atf_tc_fail_nonfatal("floorf(+0.0) != +0.0");
553 ATF_TC(floorl_basic
);
554 ATF_TC_HEAD(floorl_basic
, tc
)
556 atf_tc_set_md_var(tc
, "descr", "A basic test of floorl(3)");
559 ATF_TC_BODY(floorl_basic
, tc
)
561 const long double x
= 0.9999999;
562 const long double y
= 0.0000001;
564 ATF_CHECK(floorl(x
) < SMALL_NUM
);
565 ATF_CHECK(floorl(y
) < SMALL_NUM
);
569 ATF_TC_HEAD(floorl_nan
, tc
)
571 atf_tc_set_md_var(tc
, "descr", "Test floorl(NaN) == NaN");
574 ATF_TC_BODY(floorl_nan
, tc
)
577 const long double x
= 0.0L / 0.0L;
579 ATF_CHECK(isnan(floorl(x
)) != 0);
583 ATF_TC(floorl_inf_neg
);
584 ATF_TC_HEAD(floorl_inf_neg
, tc
)
586 atf_tc_set_md_var(tc
, "descr", "Test floorl(-Inf) == -Inf");
589 ATF_TC_BODY(floorl_inf_neg
, tc
)
592 const long double x
= -1.0L / 0.0L;
593 long double y
= floorl(x
);
595 if (isinf(y
) == 0 || signbit(y
) == 0)
596 atf_tc_fail_nonfatal("floorl(-Inf) != -Inf");
600 ATF_TC(floorl_inf_pos
);
601 ATF_TC_HEAD(floorl_inf_pos
, tc
)
603 atf_tc_set_md_var(tc
, "descr", "Test floorl(+Inf) == +Inf");
606 ATF_TC_BODY(floorl_inf_pos
, tc
)
609 const long double x
= 1.0L / 0.0L;
610 long double y
= floorl(x
);
612 if (isinf(y
) == 0 || signbit(y
) != 0)
613 atf_tc_fail_nonfatal("floorl(+Inf) != +Inf");
617 ATF_TC(floorl_zero_neg
);
618 ATF_TC_HEAD(floorl_zero_neg
, tc
)
620 atf_tc_set_md_var(tc
, "descr", "Test floorl(-0.0) == -0.0");
623 ATF_TC_BODY(floorl_zero_neg
, tc
)
626 const long double x
= -0.0L;
627 long double y
= floorl(x
);
629 if (fabsl(y
) > 0.0 || signbit(y
) == 0)
630 atf_tc_fail_nonfatal("floorl(-0.0) != -0.0");
634 ATF_TC(floorl_zero_pos
);
635 ATF_TC_HEAD(floorl_zero_pos
, tc
)
637 atf_tc_set_md_var(tc
, "descr", "Test floorl(+0.0) == +0.0");
640 ATF_TC_BODY(floorl_zero_pos
, tc
)
643 const long double x
= 0.0L;
644 long double y
= floorl(x
);
646 if (fabsl(y
) > 0.0 || signbit(y
) != 0)
647 atf_tc_fail_nonfatal("floorl(+0.0) != +0.0");
655 ATF_TC_HEAD(trunc_basic
, tc
)
657 atf_tc_set_md_var(tc
, "descr", "A basic test of trunc(3)");
660 ATF_TC_BODY(trunc_basic
, tc
)
662 const double x
= 0.999999999999999;
663 const double y
= 0.000000000000001;
665 ATF_CHECK(trunc(x
) < SMALL_NUM
);
666 ATF_CHECK(trunc(y
) < SMALL_NUM
);
670 ATF_TC_HEAD(trunc_nan
, tc
)
672 atf_tc_set_md_var(tc
, "descr", "Test trunc(NaN) == NaN");
675 ATF_TC_BODY(trunc_nan
, tc
)
678 const double x
= 0.0L / 0.0L;
680 ATF_CHECK(isnan(trunc(x
)) != 0);
684 ATF_TC(trunc_inf_neg
);
685 ATF_TC_HEAD(trunc_inf_neg
, tc
)
687 atf_tc_set_md_var(tc
, "descr", "Test trunc(-Inf) == -Inf");
690 ATF_TC_BODY(trunc_inf_neg
, tc
)
693 const double x
= -1.0L / 0.0L;
696 if (isinf(y
) == 0 || signbit(y
) == 0)
697 atf_tc_fail_nonfatal("trunc(-Inf) != -Inf");
701 ATF_TC(trunc_inf_pos
);
702 ATF_TC_HEAD(trunc_inf_pos
, tc
)
704 atf_tc_set_md_var(tc
, "descr", "Test trunc(+Inf) == +Inf");
707 ATF_TC_BODY(trunc_inf_pos
, tc
)
710 const double x
= 1.0L / 0.0L;
713 if (isinf(y
) == 0 || signbit(y
) != 0)
714 atf_tc_fail_nonfatal("trunc(+Inf) != +Inf");
718 ATF_TC(trunc_zero_neg
);
719 ATF_TC_HEAD(trunc_zero_neg
, tc
)
721 atf_tc_set_md_var(tc
, "descr", "Test trunc(-0.0) == -0.0");
724 ATF_TC_BODY(trunc_zero_neg
, tc
)
727 const double x
= -0.0L;
730 if (fabs(y
) > 0.0 || signbit(y
) == 0)
731 atf_tc_fail_nonfatal("trunc(-0.0) != -0.0");
735 ATF_TC(trunc_zero_pos
);
736 ATF_TC_HEAD(trunc_zero_pos
, tc
)
738 atf_tc_set_md_var(tc
, "descr", "Test trunc(+0.0) == +0.0");
741 ATF_TC_BODY(trunc_zero_pos
, tc
)
744 const double x
= 0.0L;
747 if (fabs(y
) > 0.0 || signbit(y
) != 0)
748 atf_tc_fail_nonfatal("trunc(+0.0) != +0.0");
755 ATF_TC(truncf_basic
);
756 ATF_TC_HEAD(truncf_basic
, tc
)
758 atf_tc_set_md_var(tc
, "descr", "A basic test of truncf(3)");
761 ATF_TC_BODY(truncf_basic
, tc
)
763 const float x
= 0.9999999;
764 const float y
= 0.0000001;
766 ATF_CHECK(truncf(x
) < SMALL_NUM
);
767 ATF_CHECK(truncf(y
) < SMALL_NUM
);
771 ATF_TC_HEAD(truncf_nan
, tc
)
773 atf_tc_set_md_var(tc
, "descr", "Test truncf(NaN) == NaN");
776 ATF_TC_BODY(truncf_nan
, tc
)
779 const float x
= 0.0L / 0.0L;
781 ATF_CHECK(isnan(truncf(x
)) != 0);
785 ATF_TC(truncf_inf_neg
);
786 ATF_TC_HEAD(truncf_inf_neg
, tc
)
788 atf_tc_set_md_var(tc
, "descr", "Test truncf(-Inf) == -Inf");
791 ATF_TC_BODY(truncf_inf_neg
, tc
)
794 const float x
= -1.0L / 0.0L;
797 if (isinf(y
) == 0 || signbit(y
) == 0)
798 atf_tc_fail_nonfatal("truncf(-Inf) != -Inf");
802 ATF_TC(truncf_inf_pos
);
803 ATF_TC_HEAD(truncf_inf_pos
, tc
)
805 atf_tc_set_md_var(tc
, "descr", "Test truncf(+Inf) == +Inf");
808 ATF_TC_BODY(truncf_inf_pos
, tc
)
811 const float x
= 1.0L / 0.0L;
814 if (isinf(y
) == 0 || signbit(y
) != 0)
815 atf_tc_fail_nonfatal("truncf(+Inf) != +Inf");
819 ATF_TC(truncf_zero_neg
);
820 ATF_TC_HEAD(truncf_zero_neg
, tc
)
822 atf_tc_set_md_var(tc
, "descr", "Test truncf(-0.0) == -0.0");
825 ATF_TC_BODY(truncf_zero_neg
, tc
)
828 const float x
= -0.0L;
831 if (fabsf(y
) > 0.0 || signbit(y
) == 0)
832 atf_tc_fail_nonfatal("truncf(-0.0) != -0.0");
836 ATF_TC(truncf_zero_pos
);
837 ATF_TC_HEAD(truncf_zero_pos
, tc
)
839 atf_tc_set_md_var(tc
, "descr", "Test truncf(+0.0) == +0.0");
842 ATF_TC_BODY(truncf_zero_pos
, tc
)
845 const float x
= 0.0L;
848 if (fabsf(y
) > 0.0 || signbit(y
) != 0)
849 atf_tc_fail_nonfatal("truncf(+0.0) != +0.0");
856 ATF_TC(truncl_basic
);
857 ATF_TC_HEAD(truncl_basic
, tc
)
859 atf_tc_set_md_var(tc
, "descr", "A basic test of truncl(3)");
862 ATF_TC_BODY(truncl_basic
, tc
)
864 const long double x
= 0.9999999;
865 const long double y
= 0.0000001;
867 ATF_CHECK(truncl(x
) < SMALL_NUM
);
868 ATF_CHECK(truncl(y
) < SMALL_NUM
);
872 ATF_TC_HEAD(truncl_nan
, tc
)
874 atf_tc_set_md_var(tc
, "descr", "Test truncl(NaN) == NaN");
877 ATF_TC_BODY(truncl_nan
, tc
)
880 const long double x
= 0.0L / 0.0L;
882 ATF_CHECK(isnan(truncl(x
)) != 0);
886 ATF_TC(truncl_inf_neg
);
887 ATF_TC_HEAD(truncl_inf_neg
, tc
)
889 atf_tc_set_md_var(tc
, "descr", "Test truncl(-Inf) == -Inf");
892 ATF_TC_BODY(truncl_inf_neg
, tc
)
895 const long double x
= -1.0L / 0.0L;
896 long double y
= truncl(x
);
898 if (isinf(y
) == 0 || signbit(y
) == 0)
899 atf_tc_fail_nonfatal("truncl(-Inf) != -Inf");
903 ATF_TC(truncl_inf_pos
);
904 ATF_TC_HEAD(truncl_inf_pos
, tc
)
906 atf_tc_set_md_var(tc
, "descr", "Test truncl(+Inf) == +Inf");
909 ATF_TC_BODY(truncl_inf_pos
, tc
)
912 const long double x
= 1.0L / 0.0L;
913 long double y
= truncl(x
);
915 if (isinf(y
) == 0 || signbit(y
) != 0)
916 atf_tc_fail_nonfatal("truncl(+Inf) != +Inf");
920 ATF_TC(truncl_zero_neg
);
921 ATF_TC_HEAD(truncl_zero_neg
, tc
)
923 atf_tc_set_md_var(tc
, "descr", "Test truncl(-0.0) == -0.0");
926 ATF_TC_BODY(truncl_zero_neg
, tc
)
929 const long double x
= -0.0L;
930 long double y
= truncl(x
);
932 if (fabsl(y
) > 0.0 || signbit(y
) == 0)
933 atf_tc_fail_nonfatal("truncl(-0.0) != -0.0");
937 ATF_TC(truncl_zero_pos
);
938 ATF_TC_HEAD(truncl_zero_pos
, tc
)
940 atf_tc_set_md_var(tc
, "descr", "Test truncl(+0.0) == +0.0");
943 ATF_TC_BODY(truncl_zero_pos
, tc
)
946 const long double x
= 0.0L;
947 long double y
= truncl(x
);
949 if (fabsl(y
) > 0.0 || signbit(y
) != 0)
950 atf_tc_fail_nonfatal("truncl(+0.0) != +0.0");
957 ATF_TP_ADD_TC(tp
, ceil_basic
);
958 ATF_TP_ADD_TC(tp
, ceil_nan
);
959 ATF_TP_ADD_TC(tp
, ceil_inf_neg
);
960 ATF_TP_ADD_TC(tp
, ceil_inf_pos
);
961 ATF_TP_ADD_TC(tp
, ceil_zero_neg
);
962 ATF_TP_ADD_TC(tp
, ceil_zero_pos
);
964 ATF_TP_ADD_TC(tp
, ceilf_basic
);
965 ATF_TP_ADD_TC(tp
, ceilf_nan
);
966 ATF_TP_ADD_TC(tp
, ceilf_inf_neg
);
967 ATF_TP_ADD_TC(tp
, ceilf_inf_pos
);
968 ATF_TP_ADD_TC(tp
, ceilf_zero_neg
);
969 ATF_TP_ADD_TC(tp
, ceilf_zero_pos
);
971 ATF_TP_ADD_TC(tp
, ceill_basic
);
972 ATF_TP_ADD_TC(tp
, ceill_nan
);
973 ATF_TP_ADD_TC(tp
, ceill_inf_neg
);
974 ATF_TP_ADD_TC(tp
, ceill_inf_pos
);
975 ATF_TP_ADD_TC(tp
, ceill_zero_neg
);
976 ATF_TP_ADD_TC(tp
, ceill_zero_pos
);
978 ATF_TP_ADD_TC(tp
, floor_basic
);
979 ATF_TP_ADD_TC(tp
, floor_nan
);
980 ATF_TP_ADD_TC(tp
, floor_inf_neg
);
981 ATF_TP_ADD_TC(tp
, floor_inf_pos
);
982 ATF_TP_ADD_TC(tp
, floor_zero_neg
);
983 ATF_TP_ADD_TC(tp
, floor_zero_pos
);
985 ATF_TP_ADD_TC(tp
, floorf_basic
);
986 ATF_TP_ADD_TC(tp
, floorf_nan
);
987 ATF_TP_ADD_TC(tp
, floorf_inf_neg
);
988 ATF_TP_ADD_TC(tp
, floorf_inf_pos
);
989 ATF_TP_ADD_TC(tp
, floorf_zero_neg
);
990 ATF_TP_ADD_TC(tp
, floorf_zero_pos
);
992 ATF_TP_ADD_TC(tp
, floorl_basic
);
993 ATF_TP_ADD_TC(tp
, floorl_nan
);
994 ATF_TP_ADD_TC(tp
, floorl_inf_neg
);
995 ATF_TP_ADD_TC(tp
, floorl_inf_pos
);
996 ATF_TP_ADD_TC(tp
, floorl_zero_neg
);
997 ATF_TP_ADD_TC(tp
, floorl_zero_pos
);
999 ATF_TP_ADD_TC(tp
, trunc_basic
);
1000 ATF_TP_ADD_TC(tp
, trunc_nan
);
1001 ATF_TP_ADD_TC(tp
, trunc_inf_neg
);
1002 ATF_TP_ADD_TC(tp
, trunc_inf_pos
);
1003 ATF_TP_ADD_TC(tp
, trunc_zero_neg
);
1004 ATF_TP_ADD_TC(tp
, trunc_zero_pos
);
1006 ATF_TP_ADD_TC(tp
, truncf_basic
);
1007 ATF_TP_ADD_TC(tp
, truncf_nan
);
1008 ATF_TP_ADD_TC(tp
, truncf_inf_neg
);
1009 ATF_TP_ADD_TC(tp
, truncf_inf_pos
);
1010 ATF_TP_ADD_TC(tp
, truncf_zero_neg
);
1011 ATF_TP_ADD_TC(tp
, truncf_zero_pos
);
1013 ATF_TP_ADD_TC(tp
, truncl_basic
);
1014 ATF_TP_ADD_TC(tp
, truncl_nan
);
1015 ATF_TP_ADD_TC(tp
, truncl_inf_neg
);
1016 ATF_TP_ADD_TC(tp
, truncl_inf_pos
);
1017 ATF_TP_ADD_TC(tp
, truncl_zero_neg
);
1018 ATF_TP_ADD_TC(tp
, truncl_zero_pos
);
1020 return atf_no_error();