]> sourceware.org Git - glibc.git/commitdiff
Add test for CMPLX macros
authorUlrich Drepper <drepper@gmail.com>
Sun, 8 Jan 2012 21:02:45 +0000 (16:02 -0500)
committerUlrich Drepper <drepper@gmail.com>
Sun, 8 Jan 2012 21:02:45 +0000 (16:02 -0500)
ChangeLog
math/Makefile
math/tst-CMPLX.c [new file with mode: 0644]

index 8c48331bb06cbc6a0fe3f4632a637bac5377703a..bec9b38e14280e5e4d09ed83c35ae6d85d896791 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2012-01-08  Ulrich Drepper  <drepper@gmail.com>
 
+       * math/Makefile (tests): Add tst-CMPLX.
+       * math/test-CMPLX.c: New file.
+
        * math/complex.h (CMPLXL): Fix typo.
 
        * debug/Makefile (routines): Add poll_chk and ppoll_chk.
index 28195505cef07d8f37c8f988bf98f119269f0fa1..7ccbc11030eed65de145d3852f894c00fdd73ee9 100644 (file)
@@ -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 (file)
index 0000000..2c32438
--- /dev/null
@@ -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"
This page took 0.050548 seconds and 5 git commands to generate.