summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2015-07-16 13:29:12 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2015-07-16 13:29:12 +0000
commit486c2b0566bb358e74fba997c24ae803c277cc6e (patch)
tree25267f3d00a5a99e5e65acd7a16cdfba4abf4df6 /regress
parent6c55f05c348ad63d4f9cf6541b718b1802b42b4a (diff)
Signs of cacosh/cacoshf were not always correct (e.g., -1.1 -1.1i),
as found by fortran regression tests. Also added some complex regression tests for cacosh, casinh, catanh. Reported by John Marino @ DragonFlyBSD.
Diffstat (limited to 'regress')
-rw-r--r--regress/lib/libm/complex/Makefile7
-rw-r--r--regress/lib/libm/complex/complex.c42
2 files changed, 49 insertions, 0 deletions
diff --git a/regress/lib/libm/complex/Makefile b/regress/lib/libm/complex/Makefile
new file mode 100644
index 00000000000..c3648851c8a
--- /dev/null
+++ b/regress/lib/libm/complex/Makefile
@@ -0,0 +1,7 @@
+# $OpenBSD: Makefile,v 1.1 2015/07/16 13:29:11 martynas Exp $
+
+PROG=complex
+LDADD=-lm
+DPADD=${LIBM}
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/libm/complex/complex.c b/regress/lib/libm/complex/complex.c
new file mode 100644
index 00000000000..133cfafe017
--- /dev/null
+++ b/regress/lib/libm/complex/complex.c
@@ -0,0 +1,42 @@
+/* $OpenBSD: complex.c,v 1.1 2015/07/16 13:29:11 martynas Exp $ */
+
+/*
+ * Written by Martynas Venckus. Public domain
+ */
+
+#include <assert.h>
+#include <complex.h>
+#include <math.h>
+
+#define PREC 1000
+#define test(f, r, i) ( \
+ floor((__real__ (f)) * PREC) == floor((r) * PREC) && \
+ floor((__imag__ (f)) * PREC) == floor((i) * PREC) \
+)
+#define testf(f, r, i) ( \
+ floorf((__real__ (f)) * PREC) == floorf((r) * PREC) && \
+ floorf((__imag__ (f)) * PREC) == floorf((i) * PREC) \
+)
+
+int
+main(int argc, char *argv[])
+{
+ double complex r, z4 = -1.1 - 1.1 * I;
+ float complex rf, z4f = -1.1 - 1.1 * I;
+
+ r = cacosh(z4);
+ assert(test(r, 1.150127, -2.256295));
+ r = casinh(z4);
+ assert(test(r, -1.150127, -0.685498));
+ r = catanh(z4);
+ assert(test(r, -0.381870, -1.071985));
+
+ rf = cacoshf(z4f);
+ assert(testf(rf, 1.150127, -2.256295));
+ rf = casinhf(z4f);
+ assert(testf(rf, -1.150127, -0.685498));
+ rf = catanhf(z4f);
+ assert(testf(rf, -0.381870, -1.071985));
+
+ return (0);
+}