Bug 23308: Update to Unicode 11.0.0
[glibc.git] / math / libm-test-driver.c
blob30646da862b2b6c7cba282299e7d7f592f3d8108
1 /* Support code for testing libm functions (driver).
2 Copyright (C) 1997-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include "libm-test-support.h"
21 #include <math-tests-arch.h>
23 /* Flags set by the including file. */
24 const int flag_test_errno = TEST_ERRNO;
25 const int flag_test_exceptions = TEST_EXCEPTIONS;
26 const int flag_test_finite = TEST_FINITE;
27 const int flag_test_inline = TEST_INLINE;
28 const int flag_test_mathvec = TEST_MATHVEC;
30 #if TEST_NARROW
31 const int snan_tests_arg = SNAN_TESTS (ARG_FLOAT);
32 #else
33 const int snan_tests_arg = SNAN_TESTS (FLOAT);
34 #endif
36 #define STRX(x) #x
37 #define STR(x) STRX (x)
38 #define STR_FLOAT STR (FLOAT)
39 #define STR_ARG_FLOAT STR (ARG_FLOAT)
40 #define STR_VEC_LEN STR (VEC_LEN)
42 /* Informal description of the functions being tested. */
43 #if TEST_MATHVEC
44 # define TEST_MSG "testing " STR_FLOAT " (vector length " STR_VEC_LEN ")\n"
45 #elif TEST_INLINE
46 # define TEST_MSG "testing " STR_FLOAT " (inline functions)\n"
47 #elif TEST_FINITE
48 # define TEST_MSG "testing " STR_FLOAT " (finite-math-only)\n"
49 #elif TEST_NARROW
50 # define TEST_MSG "testing " STR_FLOAT " (argument " STR_ARG_FLOAT ")\n"
51 #else
52 # define TEST_MSG "testing " STR_FLOAT " (without inline functions)\n"
53 #endif
54 const char test_msg[] = TEST_MSG;
56 /* Allow platforms without all rounding modes to test properly,
57 assuming they provide an __FE_UNDEFINED in <bits/fenv.h> which
58 causes fesetround() to return failure. */
59 #ifndef FE_TONEAREST
60 # define FE_TONEAREST __FE_UNDEFINED
61 #endif
62 #ifndef FE_TOWARDZERO
63 # define FE_TOWARDZERO __FE_UNDEFINED
64 #endif
65 #ifndef FE_UPWARD
66 # define FE_UPWARD __FE_UNDEFINED
67 #endif
68 #ifndef FE_DOWNWARD
69 # define FE_DOWNWARD __FE_UNDEFINED
70 #endif
72 #define TEST_NAN_PAYLOAD_CANONICALIZE (SNAN_TESTS_PRESERVE_PAYLOAD \
73 ? TEST_NAN_PAYLOAD \
74 : 0)
76 #if TEST_INLINE
77 const char qtype_str[] = "i" TYPE_STR;
78 #else
79 const char qtype_str[] = TYPE_STR;
80 #endif
82 /* Various constants derived from pi. We must supply them precalculated for
83 accuracy. They are written as a series of postfix operations to keep
84 them concise yet somewhat readable. */
86 /* (pi * 3) / 4 */
87 #define lit_pi_3_m_4_d LIT (2.356194490192344928846982537459627163)
88 /* pi * 3 / (4 * ln(10)) */
89 #define lit_pi_3_m_4_ln10_m_d LIT (1.023282265381381010614337719073516828)
90 /* pi / (2 * ln(10)) */
91 #define lit_pi_2_ln10_m_d LIT (0.682188176920920673742891812715677885)
92 /* pi / (4 * ln(10)) */
93 #define lit_pi_4_ln10_m_d LIT (0.341094088460460336871445906357838943)
94 /* pi / ln(10) */
95 #define lit_pi_ln10_d LIT (1.364376353841841347485783625431355770)
96 /* pi / 2 */
97 #define lit_pi_2_d LITM (M_PI_2)
98 /* pi / 4 */
99 #define lit_pi_4_d LITM (M_PI_4)
100 /* pi */
101 #define lit_pi LITM (M_PI)
103 /* Other useful constants. */
105 /* e */
106 #define lit_e LITM (M_E)
108 #define plus_zero LIT (0.0)
109 #define minus_zero LIT (-0.0)
110 #define plus_infty FUNC (__builtin_inf) ()
111 #define minus_infty -(FUNC (__builtin_inf) ())
112 #define qnan_value_pl(S) FUNC (__builtin_nan) (S)
113 #define qnan_value qnan_value_pl ("")
114 #define snan_value_pl(S) FUNC (__builtin_nans) (S)
115 #define snan_value snan_value_pl ("")
116 #define max_value TYPE_MAX
117 #define min_value TYPE_MIN
118 #define min_subnorm_value TYPE_TRUE_MIN
120 #define arg_plus_zero ARG_LIT (0.0)
121 #define arg_minus_zero ARG_LIT (-0.0)
122 #define arg_plus_infty ARG_FUNC (__builtin_inf) ()
123 #define arg_minus_infty -(ARG_FUNC (__builtin_inf) ())
124 #define arg_qnan_value_pl(S) ARG_FUNC (__builtin_nan) (S)
125 #define arg_qnan_value arg_qnan_value_pl ("")
126 #define arg_snan_value_pl(S) ARG_FUNC (__builtin_nans) (S)
127 #define arg_snan_value arg_snan_value_pl ("")
128 #define arg_max_value ARG_TYPE_MAX
129 #define arg_min_value ARG_TYPE_MIN
130 #define arg_min_subnorm_value ARG_TYPE_TRUE_MIN
132 /* For nexttoward tests. */
133 #define snan_value_ld __builtin_nansl ("")
135 /* Structures for each kind of test. */
136 /* Used for both RUN_TEST_LOOP_f_f and RUN_TEST_LOOP_fp_f. */
137 struct test_f_f_data
139 const char *arg_str;
140 FLOAT arg;
141 struct
143 FLOAT expected;
144 int exceptions;
145 } rd, rn, rz, ru;
147 struct test_ff_f_data
149 const char *arg_str;
150 FLOAT arg1, arg2;
151 struct
153 FLOAT expected;
154 int exceptions;
155 } rd, rn, rz, ru;
157 /* Strictly speaking, a j type argument is one gen-libm-test.pl will not
158 attempt to muck with. For now, it is only used to prevent it from
159 mucking up an explicitly long double argument. */
160 struct test_fj_f_data
162 const char *arg_str;
163 FLOAT arg1;
164 long double arg2;
165 struct
167 FLOAT expected;
168 int exceptions;
169 } rd, rn, rz, ru;
171 #ifdef ARG_FLOAT
172 struct test_aa_f_data
174 const char *arg_str;
175 ARG_FLOAT arg1, arg2;
176 struct
178 FLOAT expected;
179 int exceptions;
180 } rd, rn, rz, ru;
182 #endif
183 struct test_fi_f_data
185 const char *arg_str;
186 FLOAT arg1;
187 int arg2;
188 struct
190 FLOAT expected;
191 int exceptions;
192 } rd, rn, rz, ru;
194 struct test_fl_f_data
196 const char *arg_str;
197 FLOAT arg1;
198 long int arg2;
199 struct
201 FLOAT expected;
202 int exceptions;
203 } rd, rn, rz, ru;
205 struct test_if_f_data
207 const char *arg_str;
208 int arg1;
209 FLOAT arg2;
210 struct
212 FLOAT expected;
213 int exceptions;
214 } rd, rn, rz, ru;
216 struct test_fff_f_data
218 const char *arg_str;
219 FLOAT arg1, arg2, arg3;
220 struct
222 FLOAT expected;
223 int exceptions;
224 } rd, rn, rz, ru;
226 struct test_fiu_M_data
228 const char *arg_str;
229 FLOAT arg1;
230 int arg2;
231 unsigned int arg3;
232 struct
234 intmax_t expected;
235 int exceptions;
236 } rd, rn, rz, ru;
238 struct test_fiu_U_data
240 const char *arg_str;
241 FLOAT arg1;
242 int arg2;
243 unsigned int arg3;
244 struct
246 uintmax_t expected;
247 int exceptions;
248 } rd, rn, rz, ru;
250 struct test_c_f_data
252 const char *arg_str;
253 FLOAT argr, argc;
254 struct
256 FLOAT expected;
257 int exceptions;
258 } rd, rn, rz, ru;
260 /* Used for both RUN_TEST_LOOP_f_f1 and RUN_TEST_LOOP_fI_f1. */
261 struct test_f_f1_data
263 const char *arg_str;
264 FLOAT arg;
265 struct
267 FLOAT expected;
268 int exceptions;
269 int extra_test;
270 int extra_expected;
271 } rd, rn, rz, ru;
273 struct test_fF_f1_data
275 const char *arg_str;
276 FLOAT arg;
277 struct
279 FLOAT expected;
280 int exceptions;
281 int extra_test;
282 FLOAT extra_expected;
283 } rd, rn, rz, ru;
285 struct test_ffI_f1_data
287 const char *arg_str;
288 FLOAT arg1, arg2;
289 struct
291 FLOAT expected;
292 int exceptions;
293 int extra_test;
294 int extra_expected;
295 } rd, rn, rz, ru;
297 struct test_c_c_data
299 const char *arg_str;
300 FLOAT argr, argc;
301 struct
303 FLOAT expr, expc;
304 int exceptions;
305 } rd, rn, rz, ru;
307 struct test_cc_c_data
309 const char *arg_str;
310 FLOAT arg1r, arg1c, arg2r, arg2c;
311 struct
313 FLOAT expr, expc;
314 int exceptions;
315 } rd, rn, rz, ru;
317 /* Used for all of RUN_TEST_LOOP_f_i, RUN_TEST_LOOP_f_i_tg,
318 RUN_TEST_LOOP_f_b and RUN_TEST_LOOP_f_b_tg. */
319 struct test_f_i_data
321 const char *arg_str;
322 FLOAT arg;
323 struct
325 int expected;
326 int exceptions;
327 } rd, rn, rz, ru;
329 /* Used for both RUN_TEST_LOOP_ff_b and RUN_TEST_LOOP_ff_i_tg. */
330 struct test_ff_i_data
332 const char *arg_str;
333 FLOAT arg1, arg2;
334 struct
336 int expected;
337 int exceptions;
338 } rd, rn, rz, ru;
340 struct test_f_l_data
342 const char *arg_str;
343 FLOAT arg;
344 struct
346 long int expected;
347 int exceptions;
348 } rd, rn, rz, ru;
350 struct test_f_L_data
352 const char *arg_str;
353 FLOAT arg;
354 struct
356 long long int expected;
357 int exceptions;
358 } rd, rn, rz, ru;
360 struct test_fFF_11_data
362 const char *arg_str;
363 FLOAT arg;
364 struct
366 int exceptions;
367 int extra1_test;
368 FLOAT extra1_expected;
369 int extra2_test;
370 FLOAT extra2_expected;
371 } rd, rn, rz, ru;
373 /* Used for both RUN_TEST_LOOP_Ff_b1 and RUN_TEST_LOOP_Ffp_b1. */
374 struct test_Ff_b1_data
376 const char *arg_str;
377 FLOAT arg;
378 struct
380 int expected;
381 int exceptions;
382 int extra_test;
383 FLOAT extra_expected;
384 } rd, rn, rz, ru;
387 /* Set the rounding mode, or restore the saved value. */
388 #define IF_ROUND_INIT_ /* Empty. */
389 #define IF_ROUND_INIT_FE_DOWNWARD \
390 int save_round_mode = fegetround (); \
391 if (ROUNDING_TESTS (FLOAT, FE_DOWNWARD) \
392 && fesetround (FE_DOWNWARD) == 0)
393 #define IF_ROUND_INIT_FE_TONEAREST \
394 int save_round_mode = fegetround (); \
395 if (ROUNDING_TESTS (FLOAT, FE_TONEAREST) \
396 && fesetround (FE_TONEAREST) == 0)
397 #define IF_ROUND_INIT_FE_TOWARDZERO \
398 int save_round_mode = fegetround (); \
399 if (ROUNDING_TESTS (FLOAT, FE_TOWARDZERO) \
400 && fesetround (FE_TOWARDZERO) == 0)
401 #define IF_ROUND_INIT_FE_UPWARD \
402 int save_round_mode = fegetround (); \
403 if (ROUNDING_TESTS (FLOAT, FE_UPWARD) \
404 && fesetround (FE_UPWARD) == 0)
405 #define ROUND_RESTORE_ /* Empty. */
406 #define ROUND_RESTORE_FE_DOWNWARD \
407 fesetround (save_round_mode)
408 #define ROUND_RESTORE_FE_TONEAREST \
409 fesetround (save_round_mode)
410 #define ROUND_RESTORE_FE_TOWARDZERO \
411 fesetround (save_round_mode)
412 #define ROUND_RESTORE_FE_UPWARD \
413 fesetround (save_round_mode)
415 /* Field name to use for a given rounding mode. */
416 #define RM_ rn
417 #define RM_FE_DOWNWARD rd
418 #define RM_FE_TONEAREST rn
419 #define RM_FE_TOWARDZERO rz
420 #define RM_FE_UPWARD ru
422 /* Common setup for an individual test. */
423 #define COMMON_TEST_SETUP(ARG_STR) \
424 char *test_name; \
425 if (asprintf (&test_name, "%s (%s)", this_func, (ARG_STR)) == -1) \
426 abort ()
428 /* Setup for a test with an extra output. */
429 #define EXTRA_OUTPUT_TEST_SETUP(ARG_STR, N) \
430 char *extra##N##_name; \
431 if (asprintf (&extra##N##_name, "%s (%s) extra output " #N, \
432 this_func, (ARG_STR)) == -1) \
433 abort ()
435 /* Common cleanup after an individual test. */
436 #define COMMON_TEST_CLEANUP \
437 free (test_name)
439 /* Cleanup for a test with an extra output. */
440 #define EXTRA_OUTPUT_TEST_CLEANUP(N) \
441 free (extra##N##_name)
443 /* Run an individual test, including any required setup and checking
444 of results, or loop over all tests in an array. */
445 #define RUN_TEST_f_f(ARG_STR, FUNC_NAME, ARG, EXPECTED, \
446 EXCEPTIONS) \
447 do \
448 if (enable_test (EXCEPTIONS)) \
450 COMMON_TEST_SETUP (ARG_STR); \
451 check_float (test_name, FUNC_TEST (FUNC_NAME) (ARG), \
452 EXPECTED, EXCEPTIONS); \
453 COMMON_TEST_CLEANUP; \
455 while (0)
456 #define RUN_TEST_LOOP_f_f(FUNC_NAME, ARRAY, ROUNDING_MODE) \
457 IF_ROUND_INIT_ ## ROUNDING_MODE \
458 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
459 RUN_TEST_f_f ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
460 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
461 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
462 ROUND_RESTORE_ ## ROUNDING_MODE
463 #define RUN_TEST_fp_f(ARG_STR, FUNC_NAME, ARG, EXPECTED, \
464 EXCEPTIONS) \
465 do \
466 if (enable_test (EXCEPTIONS)) \
468 COMMON_TEST_SETUP (ARG_STR); \
469 check_float (test_name, FUNC_TEST (FUNC_NAME) (&(ARG)), \
470 EXPECTED, EXCEPTIONS); \
471 COMMON_TEST_CLEANUP; \
473 while (0)
474 #define RUN_TEST_LOOP_fp_f(FUNC_NAME, ARRAY, ROUNDING_MODE) \
475 IF_ROUND_INIT_ ## ROUNDING_MODE \
476 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
477 RUN_TEST_fp_f ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
478 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
479 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
480 ROUND_RESTORE_ ## ROUNDING_MODE
481 #define RUN_TEST_2_f(ARG_STR, FUNC_NAME, ARG1, ARG2, EXPECTED, \
482 EXCEPTIONS) \
483 do \
484 if (enable_test (EXCEPTIONS)) \
486 COMMON_TEST_SETUP (ARG_STR); \
487 check_float (test_name, FUNC_TEST (FUNC_NAME) (ARG1, ARG2), \
488 EXPECTED, EXCEPTIONS); \
489 COMMON_TEST_CLEANUP; \
491 while (0)
492 #define RUN_TEST_LOOP_2_f(FUNC_NAME, ARRAY, ROUNDING_MODE) \
493 IF_ROUND_INIT_ ## ROUNDING_MODE \
494 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
495 RUN_TEST_2_f ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg1, \
496 (ARRAY)[i].arg2, \
497 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
498 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
499 ROUND_RESTORE_ ## ROUNDING_MODE
500 #define RUN_TEST_ff_f RUN_TEST_2_f
501 #define RUN_TEST_LOOP_ff_f RUN_TEST_LOOP_2_f
502 #define RUN_TEST_LOOP_fj_f RUN_TEST_LOOP_2_f
503 #define RUN_TEST_LOOP_aa_f RUN_TEST_LOOP_2_f
504 #define RUN_TEST_fi_f RUN_TEST_2_f
505 #define RUN_TEST_LOOP_fi_f RUN_TEST_LOOP_2_f
506 #define RUN_TEST_fl_f RUN_TEST_2_f
507 #define RUN_TEST_LOOP_fl_f RUN_TEST_LOOP_2_f
508 #define RUN_TEST_if_f RUN_TEST_2_f
509 #define RUN_TEST_LOOP_if_f RUN_TEST_LOOP_2_f
510 #define RUN_TEST_fff_f(ARG_STR, FUNC_NAME, ARG1, ARG2, ARG3, \
511 EXPECTED, EXCEPTIONS) \
512 do \
513 if (enable_test (EXCEPTIONS)) \
515 COMMON_TEST_SETUP (ARG_STR); \
516 check_float (test_name, FUNC_TEST (FUNC_NAME) (ARG1, ARG2, ARG3), \
517 EXPECTED, EXCEPTIONS); \
518 COMMON_TEST_CLEANUP; \
520 while (0)
521 #define RUN_TEST_LOOP_fff_f(FUNC_NAME, ARRAY, ROUNDING_MODE) \
522 IF_ROUND_INIT_ ## ROUNDING_MODE \
523 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
524 RUN_TEST_fff_f ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg1, \
525 (ARRAY)[i].arg2, (ARRAY)[i].arg3, \
526 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
527 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
528 ROUND_RESTORE_ ## ROUNDING_MODE
529 #define RUN_TEST_fiu_M(ARG_STR, FUNC_NAME, ARG1, ARG2, ARG3, \
530 EXPECTED, EXCEPTIONS) \
531 do \
532 if (enable_test (EXCEPTIONS)) \
534 COMMON_TEST_SETUP (ARG_STR); \
535 check_intmax_t (test_name, \
536 FUNC_TEST (FUNC_NAME) (ARG1, ARG2, ARG3), \
537 EXPECTED, EXCEPTIONS); \
538 COMMON_TEST_CLEANUP; \
540 while (0)
541 #define RUN_TEST_LOOP_fiu_M(FUNC_NAME, ARRAY, ROUNDING_MODE) \
542 IF_ROUND_INIT_ ## ROUNDING_MODE \
543 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
544 RUN_TEST_fiu_M ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg1, \
545 (ARRAY)[i].arg2, (ARRAY)[i].arg3, \
546 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
547 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
548 ROUND_RESTORE_ ## ROUNDING_MODE
549 #define RUN_TEST_fiu_U(ARG_STR, FUNC_NAME, ARG1, ARG2, ARG3, \
550 EXPECTED, EXCEPTIONS) \
551 do \
552 if (enable_test (EXCEPTIONS)) \
554 COMMON_TEST_SETUP (ARG_STR); \
555 check_uintmax_t (test_name, \
556 FUNC_TEST (FUNC_NAME) (ARG1, ARG2, ARG3), \
557 EXPECTED, EXCEPTIONS); \
558 COMMON_TEST_CLEANUP; \
560 while (0)
561 #define RUN_TEST_LOOP_fiu_U(FUNC_NAME, ARRAY, ROUNDING_MODE) \
562 IF_ROUND_INIT_ ## ROUNDING_MODE \
563 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
564 RUN_TEST_fiu_U ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg1, \
565 (ARRAY)[i].arg2, (ARRAY)[i].arg3, \
566 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
567 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
568 ROUND_RESTORE_ ## ROUNDING_MODE
569 #define RUN_TEST_c_f(ARG_STR, FUNC_NAME, ARG1, ARG2, EXPECTED, \
570 EXCEPTIONS) \
571 do \
572 if (enable_test (EXCEPTIONS)) \
574 COMMON_TEST_SETUP (ARG_STR); \
575 check_float (test_name, \
576 FUNC_TEST (FUNC_NAME) (BUILD_COMPLEX (ARG1, ARG2)),\
577 EXPECTED, EXCEPTIONS); \
578 COMMON_TEST_CLEANUP; \
580 while (0)
581 #define RUN_TEST_LOOP_c_f(FUNC_NAME, ARRAY, ROUNDING_MODE) \
582 IF_ROUND_INIT_ ## ROUNDING_MODE \
583 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
584 RUN_TEST_c_f ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].argr, \
585 (ARRAY)[i].argc, \
586 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
587 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
588 ROUND_RESTORE_ ## ROUNDING_MODE
589 #define RUN_TEST_f_f1(ARG_STR, FUNC_NAME, ARG, EXPECTED, \
590 EXCEPTIONS, EXTRA_VAR, EXTRA_TEST, \
591 EXTRA_EXPECTED) \
592 do \
593 if (enable_test (EXCEPTIONS)) \
595 COMMON_TEST_SETUP (ARG_STR); \
596 (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0; \
597 check_float (test_name, FUNC_TEST (FUNC_NAME) (ARG), EXPECTED, \
598 EXCEPTIONS); \
599 EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1); \
600 if (EXTRA_TEST) \
601 check_int (extra1_name, EXTRA_VAR, EXTRA_EXPECTED, 0); \
602 EXTRA_OUTPUT_TEST_CLEANUP (1); \
603 COMMON_TEST_CLEANUP; \
605 while (0)
606 #define RUN_TEST_LOOP_f_f1(FUNC_NAME, ARRAY, ROUNDING_MODE, EXTRA_VAR) \
607 IF_ROUND_INIT_ ## ROUNDING_MODE \
608 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
609 RUN_TEST_f_f1 ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
610 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
611 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions, \
612 EXTRA_VAR, \
613 (ARRAY)[i].RM_##ROUNDING_MODE.extra_test, \
614 (ARRAY)[i].RM_##ROUNDING_MODE.extra_expected); \
615 ROUND_RESTORE_ ## ROUNDING_MODE
616 #define RUN_TEST_fF_f1(ARG_STR, FUNC_NAME, ARG, EXPECTED, \
617 EXCEPTIONS, EXTRA_VAR, EXTRA_TEST, \
618 EXTRA_EXPECTED) \
619 do \
620 if (enable_test (EXCEPTIONS)) \
622 COMMON_TEST_SETUP (ARG_STR); \
623 (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0; \
624 check_float (test_name, FUNC_TEST (FUNC_NAME) (ARG, &(EXTRA_VAR)), \
625 EXPECTED, EXCEPTIONS); \
626 EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1); \
627 if (EXTRA_TEST) \
628 check_float (extra1_name, EXTRA_VAR, EXTRA_EXPECTED, 0); \
629 EXTRA_OUTPUT_TEST_CLEANUP (1); \
630 COMMON_TEST_CLEANUP; \
632 while (0)
633 #define RUN_TEST_LOOP_fF_f1(FUNC_NAME, ARRAY, ROUNDING_MODE, EXTRA_VAR) \
634 IF_ROUND_INIT_ ## ROUNDING_MODE \
635 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
636 RUN_TEST_fF_f1 ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
637 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
638 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions, \
639 EXTRA_VAR, \
640 (ARRAY)[i].RM_##ROUNDING_MODE.extra_test, \
641 (ARRAY)[i].RM_##ROUNDING_MODE.extra_expected); \
642 ROUND_RESTORE_ ## ROUNDING_MODE
643 #define RUN_TEST_fI_f1(ARG_STR, FUNC_NAME, ARG, EXPECTED, \
644 EXCEPTIONS, EXTRA_VAR, EXTRA_TEST, \
645 EXTRA_EXPECTED) \
646 do \
647 if (enable_test (EXCEPTIONS)) \
649 COMMON_TEST_SETUP (ARG_STR); \
650 (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0; \
651 check_float (test_name, FUNC_TEST (FUNC_NAME) (ARG, &(EXTRA_VAR)), \
652 EXPECTED, EXCEPTIONS); \
653 EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1); \
654 if (EXTRA_TEST) \
655 check_int (extra1_name, EXTRA_VAR, EXTRA_EXPECTED, 0); \
656 EXTRA_OUTPUT_TEST_CLEANUP (1); \
657 COMMON_TEST_CLEANUP; \
659 while (0)
660 #define RUN_TEST_LOOP_fI_f1(FUNC_NAME, ARRAY, ROUNDING_MODE, EXTRA_VAR) \
661 IF_ROUND_INIT_ ## ROUNDING_MODE \
662 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
663 RUN_TEST_fI_f1 ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
664 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
665 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions, \
666 EXTRA_VAR, \
667 (ARRAY)[i].RM_##ROUNDING_MODE.extra_test, \
668 (ARRAY)[i].RM_##ROUNDING_MODE.extra_expected); \
669 ROUND_RESTORE_ ## ROUNDING_MODE
670 #define RUN_TEST_ffI_f1_mod8(ARG_STR, FUNC_NAME, ARG1, ARG2, EXPECTED, \
671 EXCEPTIONS, EXTRA_VAR, EXTRA_TEST, \
672 EXTRA_EXPECTED) \
673 do \
674 if (enable_test (EXCEPTIONS)) \
676 COMMON_TEST_SETUP (ARG_STR); \
677 (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0; \
678 check_float (test_name, \
679 FUNC_TEST (FUNC_NAME) (ARG1, ARG2, &(EXTRA_VAR)), \
680 EXPECTED, EXCEPTIONS); \
681 EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1); \
682 if (EXTRA_TEST) \
683 check_int (extra1_name, (EXTRA_VAR) % 8, EXTRA_EXPECTED, 0); \
684 EXTRA_OUTPUT_TEST_CLEANUP (1); \
685 COMMON_TEST_CLEANUP; \
687 while (0)
688 #define RUN_TEST_LOOP_ffI_f1_mod8(FUNC_NAME, ARRAY, ROUNDING_MODE, \
689 EXTRA_VAR) \
690 IF_ROUND_INIT_ ## ROUNDING_MODE \
691 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
692 RUN_TEST_ffI_f1_mod8 ((ARRAY)[i].arg_str, FUNC_NAME, \
693 (ARRAY)[i].arg1, (ARRAY)[i].arg2, \
694 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
695 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions, \
696 EXTRA_VAR, \
697 (ARRAY)[i].RM_##ROUNDING_MODE.extra_test, \
698 (ARRAY)[i].RM_##ROUNDING_MODE.extra_expected); \
699 ROUND_RESTORE_ ## ROUNDING_MODE
700 #define RUN_TEST_Ff_b1(ARG_STR, FUNC_NAME, ARG, EXPECTED, \
701 EXCEPTIONS, EXTRA_VAR, EXTRA_TEST, \
702 EXTRA_EXPECTED) \
703 do \
704 if (enable_test (EXCEPTIONS)) \
706 COMMON_TEST_SETUP (ARG_STR); \
707 (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0; \
708 /* Clear any exceptions from comparison involving sNaN \
709 EXTRA_EXPECTED. */ \
710 feclearexcept (FE_ALL_EXCEPT); \
711 check_bool (test_name, FUNC_TEST (FUNC_NAME) (&(EXTRA_VAR), \
712 (ARG)), \
713 EXPECTED, EXCEPTIONS); \
714 EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1); \
715 if (EXTRA_TEST) \
716 check_float (extra1_name, EXTRA_VAR, EXTRA_EXPECTED, \
717 (EXCEPTIONS) & TEST_NAN_PAYLOAD); \
718 EXTRA_OUTPUT_TEST_CLEANUP (1); \
719 COMMON_TEST_CLEANUP; \
721 while (0)
722 #define RUN_TEST_LOOP_Ff_b1(FUNC_NAME, ARRAY, ROUNDING_MODE, \
723 EXTRA_VAR) \
724 IF_ROUND_INIT_ ## ROUNDING_MODE \
725 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
726 RUN_TEST_Ff_b1 ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
727 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
728 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions, \
729 EXTRA_VAR, \
730 (ARRAY)[i].RM_##ROUNDING_MODE.extra_test, \
731 (ARRAY)[i].RM_##ROUNDING_MODE.extra_expected); \
732 ROUND_RESTORE_ ## ROUNDING_MODE
733 #define RUN_TEST_Ffp_b1(ARG_STR, FUNC_NAME, ARG, EXPECTED, \
734 EXCEPTIONS, EXTRA_VAR, EXTRA_TEST, \
735 EXTRA_EXPECTED) \
736 do \
737 if (enable_test (EXCEPTIONS)) \
739 COMMON_TEST_SETUP (ARG_STR); \
740 (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0; \
741 check_bool (test_name, FUNC_TEST (FUNC_NAME) (&(EXTRA_VAR), \
742 &(ARG)), \
743 EXPECTED, EXCEPTIONS); \
744 EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1); \
745 if (EXTRA_TEST) \
746 check_float (extra1_name, EXTRA_VAR, EXTRA_EXPECTED, \
747 (EXCEPTIONS) & TEST_NAN_PAYLOAD); \
748 EXTRA_OUTPUT_TEST_CLEANUP (1); \
749 COMMON_TEST_CLEANUP; \
751 while (0)
752 #define RUN_TEST_LOOP_Ffp_b1(FUNC_NAME, ARRAY, ROUNDING_MODE, \
753 EXTRA_VAR) \
754 IF_ROUND_INIT_ ## ROUNDING_MODE \
755 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
756 RUN_TEST_Ffp_b1 ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
757 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
758 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions, \
759 EXTRA_VAR, \
760 (ARRAY)[i].RM_##ROUNDING_MODE.extra_test, \
761 (ARRAY)[i].RM_##ROUNDING_MODE.extra_expected); \
762 ROUND_RESTORE_ ## ROUNDING_MODE
763 #define RUN_TEST_c_c(ARG_STR, FUNC_NAME, ARGR, ARGC, EXPR, EXPC, \
764 EXCEPTIONS) \
765 do \
766 if (enable_test (EXCEPTIONS)) \
768 COMMON_TEST_SETUP (ARG_STR); \
769 check_complex (test_name, \
770 FUNC_TEST (FUNC_NAME) (BUILD_COMPLEX (ARGR, ARGC)), \
771 BUILD_COMPLEX (EXPR, EXPC), EXCEPTIONS); \
772 COMMON_TEST_CLEANUP; \
774 while (0)
775 #define RUN_TEST_LOOP_c_c(FUNC_NAME, ARRAY, ROUNDING_MODE) \
776 IF_ROUND_INIT_ ## ROUNDING_MODE \
777 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
778 RUN_TEST_c_c ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].argr, \
779 (ARRAY)[i].argc, \
780 (ARRAY)[i].RM_##ROUNDING_MODE.expr, \
781 (ARRAY)[i].RM_##ROUNDING_MODE.expc, \
782 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
783 ROUND_RESTORE_ ## ROUNDING_MODE
784 #define RUN_TEST_cc_c(ARG_STR, FUNC_NAME, ARG1R, ARG1C, ARG2R, ARG2C, \
785 EXPR, EXPC, EXCEPTIONS) \
786 do \
787 if (enable_test (EXCEPTIONS)) \
789 COMMON_TEST_SETUP (ARG_STR); \
790 check_complex (test_name, \
791 FUNC_TEST (FUNC_NAME) (BUILD_COMPLEX (ARG1R, ARG1C), \
792 BUILD_COMPLEX (ARG2R, ARG2C)), \
793 BUILD_COMPLEX (EXPR, EXPC), EXCEPTIONS); \
794 COMMON_TEST_CLEANUP; \
796 while (0)
797 #define RUN_TEST_LOOP_cc_c(FUNC_NAME, ARRAY, ROUNDING_MODE) \
798 IF_ROUND_INIT_ ## ROUNDING_MODE \
799 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
800 RUN_TEST_cc_c ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg1r, \
801 (ARRAY)[i].arg1c, (ARRAY)[i].arg2r, \
802 (ARRAY)[i].arg2c, \
803 (ARRAY)[i].RM_##ROUNDING_MODE.expr, \
804 (ARRAY)[i].RM_##ROUNDING_MODE.expc, \
805 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
806 ROUND_RESTORE_ ## ROUNDING_MODE
807 #define RUN_TEST_f_i(ARG_STR, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS) \
808 do \
809 if (enable_test (EXCEPTIONS)) \
811 COMMON_TEST_SETUP (ARG_STR); \
812 check_int (test_name, FUNC_TEST (FUNC_NAME) (ARG), EXPECTED, \
813 EXCEPTIONS); \
814 COMMON_TEST_CLEANUP; \
816 while (0)
817 #define RUN_TEST_LOOP_f_i(FUNC_NAME, ARRAY, ROUNDING_MODE) \
818 IF_ROUND_INIT_ ## ROUNDING_MODE \
819 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
820 RUN_TEST_f_i ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
821 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
822 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
823 ROUND_RESTORE_ ## ROUNDING_MODE
824 #define RUN_TEST_f_i_tg(ARG_STR, FUNC_NAME, ARG, EXPECTED, \
825 EXCEPTIONS) \
826 do \
827 if (enable_test (EXCEPTIONS)) \
829 COMMON_TEST_SETUP (ARG_STR); \
830 check_int (test_name, FUNC_NAME (ARG), EXPECTED, EXCEPTIONS); \
831 COMMON_TEST_CLEANUP; \
833 while (0)
834 #define RUN_TEST_LOOP_f_i_tg(FUNC_NAME, ARRAY, ROUNDING_MODE) \
835 IF_ROUND_INIT_ ## ROUNDING_MODE \
836 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
837 RUN_TEST_f_i_tg ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
838 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
839 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
840 ROUND_RESTORE_ ## ROUNDING_MODE
841 #define RUN_TEST_ff_b(ARG_STR, FUNC_NAME, ARG1, ARG2, EXPECTED, \
842 EXCEPTIONS) \
843 do \
844 if (enable_test (EXCEPTIONS)) \
846 COMMON_TEST_SETUP (ARG_STR); \
847 check_bool (test_name, FUNC_TEST (FUNC_NAME) (ARG1, ARG2), \
848 EXPECTED, EXCEPTIONS); \
849 COMMON_TEST_CLEANUP; \
851 while (0)
852 #define RUN_TEST_LOOP_ff_b(FUNC_NAME, ARRAY, ROUNDING_MODE) \
853 IF_ROUND_INIT_ ## ROUNDING_MODE \
854 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
855 RUN_TEST_ff_b ((ARRAY)[i].arg_str, FUNC_NAME, \
856 (ARRAY)[i].arg1, (ARRAY)[i].arg2, \
857 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
858 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
859 ROUND_RESTORE_ ## ROUNDING_MODE
860 #define RUN_TEST_ff_i_tg(ARG_STR, FUNC_NAME, ARG1, ARG2, EXPECTED, \
861 EXCEPTIONS) \
862 do \
863 if (enable_test (EXCEPTIONS)) \
865 COMMON_TEST_SETUP (ARG_STR); \
866 check_int (test_name, FUNC_NAME (ARG1, ARG2), EXPECTED, \
867 EXCEPTIONS); \
868 COMMON_TEST_CLEANUP; \
870 while (0)
871 #define RUN_TEST_LOOP_ff_i_tg(FUNC_NAME, ARRAY, ROUNDING_MODE) \
872 IF_ROUND_INIT_ ## ROUNDING_MODE \
873 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
874 RUN_TEST_ff_i_tg ((ARRAY)[i].arg_str, FUNC_NAME, \
875 (ARRAY)[i].arg1, (ARRAY)[i].arg2, \
876 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
877 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
878 ROUND_RESTORE_ ## ROUNDING_MODE
879 #define RUN_TEST_f_b(ARG_STR, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS) \
880 do \
881 if (enable_test (EXCEPTIONS)) \
883 COMMON_TEST_SETUP (ARG_STR); \
884 check_bool (test_name, FUNC_TEST (FUNC_NAME) (ARG), EXPECTED, \
885 EXCEPTIONS); \
886 COMMON_TEST_CLEANUP; \
888 while (0)
889 #define RUN_TEST_LOOP_f_b(FUNC_NAME, ARRAY, ROUNDING_MODE) \
890 IF_ROUND_INIT_ ## ROUNDING_MODE \
891 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
892 RUN_TEST_f_b ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
893 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
894 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
895 ROUND_RESTORE_ ## ROUNDING_MODE
896 #define RUN_TEST_f_b_tg(ARG_STR, FUNC_NAME, ARG, EXPECTED, \
897 EXCEPTIONS) \
898 do \
899 if (enable_test (EXCEPTIONS)) \
901 COMMON_TEST_SETUP (ARG_STR); \
902 check_bool (test_name, FUNC_NAME (ARG), EXPECTED, EXCEPTIONS); \
903 COMMON_TEST_CLEANUP; \
905 while (0)
906 #define RUN_TEST_LOOP_f_b_tg(FUNC_NAME, ARRAY, ROUNDING_MODE) \
907 IF_ROUND_INIT_ ## ROUNDING_MODE \
908 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
909 RUN_TEST_f_b_tg ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
910 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
911 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
912 ROUND_RESTORE_ ## ROUNDING_MODE
913 #define RUN_TEST_f_l(ARG_STR, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS) \
914 do \
915 if (enable_test (EXCEPTIONS)) \
917 COMMON_TEST_SETUP (ARG_STR); \
918 check_long (test_name, FUNC_TEST (FUNC_NAME) (ARG), EXPECTED, \
919 EXCEPTIONS); \
920 COMMON_TEST_CLEANUP; \
922 while (0)
923 #define RUN_TEST_LOOP_f_l(FUNC_NAME, ARRAY, ROUNDING_MODE) \
924 IF_ROUND_INIT_ ## ROUNDING_MODE \
925 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
926 RUN_TEST_f_l ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
927 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
928 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
929 ROUND_RESTORE_ ## ROUNDING_MODE
930 #define RUN_TEST_f_L(ARG_STR, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS) \
931 do \
932 if (enable_test (EXCEPTIONS)) \
934 COMMON_TEST_SETUP (ARG_STR); \
935 check_longlong (test_name, FUNC_TEST (FUNC_NAME) (ARG), \
936 EXPECTED, EXCEPTIONS); \
937 COMMON_TEST_CLEANUP; \
939 while (0)
940 #define RUN_TEST_LOOP_f_L(FUNC_NAME, ARRAY, ROUNDING_MODE) \
941 IF_ROUND_INIT_ ## ROUNDING_MODE \
942 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
943 RUN_TEST_f_L ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
944 (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
945 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
946 ROUND_RESTORE_ ## ROUNDING_MODE
947 #define RUN_TEST_fFF_11(ARG_STR, FUNC_NAME, ARG, EXCEPTIONS, \
948 EXTRA1_VAR, EXTRA1_TEST, \
949 EXTRA1_EXPECTED, EXTRA2_VAR, \
950 EXTRA2_TEST, EXTRA2_EXPECTED) \
951 do \
952 if (enable_test (EXCEPTIONS)) \
954 COMMON_TEST_SETUP (ARG_STR); \
955 FUNC_TEST (FUNC_NAME) (ARG, &(EXTRA1_VAR), &(EXTRA2_VAR)); \
956 EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1); \
957 if (EXTRA1_TEST) \
958 check_float (extra1_name, EXTRA1_VAR, EXTRA1_EXPECTED, \
959 EXCEPTIONS); \
960 EXTRA_OUTPUT_TEST_CLEANUP (1); \
961 EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 2); \
962 if (EXTRA2_TEST) \
963 check_float (extra2_name, EXTRA2_VAR, EXTRA2_EXPECTED, 0); \
964 EXTRA_OUTPUT_TEST_CLEANUP (2); \
965 COMMON_TEST_CLEANUP; \
967 while (0)
968 #define RUN_TEST_LOOP_fFF_11(FUNC_NAME, ARRAY, ROUNDING_MODE, \
969 EXTRA1_VAR, EXTRA2_VAR) \
970 IF_ROUND_INIT_ ## ROUNDING_MODE \
971 for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
972 RUN_TEST_fFF_11 ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg, \
973 (ARRAY)[i].RM_##ROUNDING_MODE.exceptions, \
974 EXTRA1_VAR, \
975 (ARRAY)[i].RM_##ROUNDING_MODE.extra1_test, \
976 (ARRAY)[i].RM_##ROUNDING_MODE.extra1_expected, \
977 EXTRA2_VAR, \
978 (ARRAY)[i].RM_##ROUNDING_MODE.extra2_test, \
979 (ARRAY)[i].RM_##ROUNDING_MODE.extra2_expected); \
980 ROUND_RESTORE_ ## ROUNDING_MODE
982 #if TEST_MATHVEC
983 # define TEST_SUFF VEC_SUFF
984 # define TEST_SUFF_STR
985 #elif TEST_NARROW
986 # define TEST_SUFF
987 # define TEST_SUFF_STR "_" ARG_TYPE_STR
988 #else
989 # define TEST_SUFF
990 # define TEST_SUFF_STR
991 #endif
993 #define STR_CONCAT(a, b, c) __STRING (a##b##c)
994 #define STR_CON3(a, b, c) STR_CONCAT (a, b, c)
996 #if TEST_NARROW
997 # define TEST_COND_any_ibm128 (TEST_COND_ibm128 || TEST_COND_arg_ibm128)
998 #else
999 # define TEST_COND_any_ibm128 TEST_COND_ibm128
1000 #endif
1002 /* Start and end the tests for a given function. */
1003 #define START(FUN, SUFF, EXACT) \
1004 CHECK_ARCH_EXT; \
1005 const char *this_func \
1006 = STR_CON3 (FUN, SUFF, TEST_SUFF) TEST_SUFF_STR; \
1007 init_max_error (this_func, EXACT, TEST_COND_any_ibm128)
1008 #define END \
1009 print_max_error (this_func)
1010 #define END_COMPLEX \
1011 print_complex_max_error (this_func)
1013 /* Run tests for a given function in all rounding modes. */
1014 #define ALL_RM_TEST(FUNC, EXACT, ARRAY, LOOP_MACRO, END_MACRO, ...) \
1015 do \
1017 do \
1019 START (FUNC,, EXACT); \
1020 LOOP_MACRO (FUNC, ARRAY, , ## __VA_ARGS__); \
1021 END_MACRO; \
1023 while (0); \
1024 do \
1026 START (FUNC, _downward, EXACT); \
1027 LOOP_MACRO (FUNC, ARRAY, FE_DOWNWARD, ## __VA_ARGS__); \
1028 END_MACRO; \
1030 while (0); \
1031 do \
1033 START (FUNC, _towardzero, EXACT); \
1034 LOOP_MACRO (FUNC, ARRAY, FE_TOWARDZERO, ## __VA_ARGS__); \
1035 END_MACRO; \
1037 while (0); \
1038 do \
1040 START (FUNC, _upward, EXACT); \
1041 LOOP_MACRO (FUNC, ARRAY, FE_UPWARD, ## __VA_ARGS__); \
1042 END_MACRO; \
1044 while (0); \
1046 while (0);
1048 /* Short description of program. */
1049 const char doc[] = "Math test suite: " TEST_MSG ;
1051 static void do_test (void);
1054 main (int argc, char **argv)
1056 libm_test_init (argc, argv);
1057 INIT_ARCH_EXT;
1058 do_test ();
1059 return libm_test_finish ();