lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <tgmath.h> |
| 3 | |
| 4 | |
| 5 | int |
| 6 | main (void) |
| 7 | { |
| 8 | int retval = 0; |
| 9 | |
| 10 | #define TEST(expr, res) \ |
| 11 | if (sizeof (expr) != res) \ |
| 12 | { \ |
| 13 | printf ("sizeof(%s) == %zu, expected %zu\n", #expr, \ |
| 14 | sizeof (expr), (size_t) (res)); \ |
| 15 | retval = 1; \ |
| 16 | } |
| 17 | |
| 18 | TEST (creal (1.0), sizeof (double)); |
| 19 | TEST (creal (1.0 + 1.0i), sizeof (double)); |
| 20 | TEST (creal (1.0l), sizeof (long double)); |
| 21 | TEST (creal (1.0l + 1.0li), sizeof (long double)); |
| 22 | TEST (creal (1.0f), sizeof (float)); |
| 23 | TEST (creal (1.0f + 1.0fi), sizeof (float)); |
| 24 | |
| 25 | TEST (cimag (1.0), sizeof (double)); |
| 26 | TEST (cimag (1.0 + 1.0i), sizeof (double)); |
| 27 | TEST (cimag (1.0l), sizeof (long double)); |
| 28 | TEST (cimag (1.0l + 1.0li), sizeof (long double)); |
| 29 | TEST (cimag (1.0f), sizeof (float)); |
| 30 | TEST (cimag (1.0f + 1.0fi), sizeof (float)); |
| 31 | |
| 32 | TEST (fabs (1.0), sizeof (double)); |
| 33 | TEST (fabs (1.0 + 1.0i), sizeof (double)); |
| 34 | TEST (fabs (1.0l), sizeof (long double)); |
| 35 | TEST (fabs (1.0l + 1.0li), sizeof (long double)); |
| 36 | TEST (fabs (1.0f), sizeof (float)); |
| 37 | TEST (fabs (1.0f + 1.0fi), sizeof (float)); |
| 38 | |
| 39 | TEST (carg (1.0), sizeof (double)); |
| 40 | TEST (carg (1.0 + 1.0i), sizeof (double)); |
| 41 | TEST (carg (1.0l), sizeof (long double)); |
| 42 | TEST (carg (1.0l + 1.0li), sizeof (long double)); |
| 43 | TEST (carg (1.0f), sizeof (float)); |
| 44 | TEST (carg (1.0f + 1.0fi), sizeof (float)); |
| 45 | |
| 46 | return retval; |
| 47 | } |