Add test for CMPLX macros
[glibc.git] / math / tst-CMPLX.c
blob2c32438729e5815f2ca7f5a74b212520efa2c129
1 #include <complex.h>
4 static int
5 do_test (void)
7 int result = 0;
9 #ifdef CMPLX
10 size_t s;
12 #define T(f, r, i, t) \
13 do { \
14 s = sizeof (f (r, i)); \
15 if (s != sizeof (complex t)) \
16 { \
17 printf ("\
18 CMPLX (" #r ", " #i ") does not produce complex " #t ": %zu\n", s); \
19 result = 1; \
20 } \
21 } while (0)
23 #define C(f, t) \
24 do { \
25 T (f, 0.0f, 0.0f, t); \
26 T (f, 0.0f, 0.0, t); \
27 T (f, 0.0f, 0.0L, t); \
28 T (f, 0.0f, 0.0f, t); \
29 T (f, 0.0, 0.0f, t); \
30 T (f, 0.0L, 0.0f, t); \
31 T (f, 0.0, 0.0f, t); \
32 T (f, 0.0, 0.0, t); \
33 T (f, 0.0, 0.0L, t); \
34 T (f, 0.0f, 0.0, t); \
35 T (f, 0.0, 0.0, t); \
36 T (f, 0.0L, 0.0, t); \
37 T (f, 0.0L, 0.0f, t); \
38 T (f, 0.0L, 0.0, t); \
39 T (f, 0.0L, 0.0L, t); \
40 T (f, 0.0f, 0.0L, t); \
41 T (f, 0.0, 0.0L, t); \
42 T (f, 0.0L, 0.0L, t); \
43 } while (0)
45 C (CMPLXF, float);
46 C (CMPLX, double);
47 # ifndef NO_LONG_DOUBLE
48 C (CMPLXL, long double);
49 # endif
50 #endif
52 return result;
55 #define TEST_FUNCTION do_test ()
56 #include "../test-skeleton.c"