about summary refs log tree commit diff
path: root/math
diff options
context:
space:
mode:
Diffstat (limited to 'math')
-rw-r--r--math/Makefile2
-rw-r--r--math/tst-CMPLX.c56
2 files changed, 57 insertions, 1 deletions
diff --git a/math/Makefile b/math/Makefile
index 28195505ce..7ccbc11030 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -91,7 +91,7 @@ distribute += $(filter-out $(generated),$(long-m-yes:=.c) $(long-c-yes:=.c))
 tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
 	test-misc test-fpucw tst-definitions test-tgmath test-tgmath-ret \
 	bug-nextafter bug-nexttoward bug-tgmath1 test-tgmath-int \
-	test-tgmath2 test-powl
+	test-tgmath2 test-powl tst-CMPLX
 # We do the `long double' tests only if this data type is available and
 # distinct from `double'.
 test-longdouble-yes = test-ldouble test-ildoubl
diff --git a/math/tst-CMPLX.c b/math/tst-CMPLX.c
new file mode 100644
index 0000000000..2c32438729
--- /dev/null
+++ b/math/tst-CMPLX.c
@@ -0,0 +1,56 @@
+#include <complex.h>
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+
+#ifdef CMPLX
+  size_t s;
+
+#define T(f, r, i, t)							      \
+  do {									      \
+    s = sizeof (f (r, i));						      \
+    if (s != sizeof (complex t))					      \
+      {									      \
+	printf ("\
+CMPLX (" #r ", " #i ") does not produce complex " #t ": %zu\n", s);	      \
+	result = 1;							      \
+      }									      \
+  } while (0)
+
+#define C(f, t)								      \
+  do {									      \
+    T (f, 0.0f, 0.0f, t);						      \
+    T (f, 0.0f, 0.0, t);						      \
+    T (f, 0.0f, 0.0L, t);						      \
+    T (f, 0.0f, 0.0f, t);						      \
+    T (f, 0.0, 0.0f, t);						      \
+    T (f, 0.0L, 0.0f, t);						      \
+    T (f, 0.0, 0.0f, t);						      \
+    T (f, 0.0, 0.0, t);							      \
+    T (f, 0.0, 0.0L, t);						      \
+    T (f, 0.0f, 0.0, t);						      \
+    T (f, 0.0, 0.0, t);							      \
+    T (f, 0.0L, 0.0, t);						      \
+    T (f, 0.0L, 0.0f, t);						      \
+    T (f, 0.0L, 0.0, t);						      \
+    T (f, 0.0L, 0.0L, t);						      \
+    T (f, 0.0f, 0.0L, t);						      \
+    T (f, 0.0, 0.0L, t);						      \
+    T (f, 0.0L, 0.0L, t);						      \
+  } while (0)
+
+  C (CMPLXF, float);
+  C (CMPLX, double);
+# ifndef NO_LONG_DOUBLE
+  C (CMPLXL, long double);
+# endif
+#endif
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"