summaryrefslogtreecommitdiff
path: root/regress/lib
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2011-05-28 22:38:07 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2011-05-28 22:38:07 +0000
commit3b99ec924ad8470a83a527aca1ba175e53a2438d (patch)
treee485c5bb795203478b7f7ae56c577961df5c9b80 /regress/lib
parent2a576aeab43e6ee183e4f7482433a23395f4ae2f (diff)
Add some simple test cases for lgamma, and lgammaf.
Currently the functions return correct results for the input of negative zero; however signgam is wrong in this case.
Diffstat (limited to 'regress/lib')
-rw-r--r--regress/lib/libm/lgamma/Makefile7
-rw-r--r--regress/lib/libm/lgamma/lgamma.c47
2 files changed, 54 insertions, 0 deletions
diff --git a/regress/lib/libm/lgamma/Makefile b/regress/lib/libm/lgamma/Makefile
new file mode 100644
index 00000000000..73a73725336
--- /dev/null
+++ b/regress/lib/libm/lgamma/Makefile
@@ -0,0 +1,7 @@
+# $OpenBSD: Makefile,v 1.1 2011/05/28 22:38:06 martynas Exp $
+
+PROG=lgamma
+LDADD=-lm
+DPADD=${LIBM}
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/libm/lgamma/lgamma.c b/regress/lib/libm/lgamma/lgamma.c
new file mode 100644
index 00000000000..c8df0969d88
--- /dev/null
+++ b/regress/lib/libm/lgamma/lgamma.c
@@ -0,0 +1,47 @@
+/* $OpenBSD: lgamma.c,v 1.1 2011/05/28 22:38:06 martynas Exp $ */
+
+/*
+ * Written by Martynas Venckus. Public domain
+ */
+
+#include <assert.h>
+#include <math.h>
+
+int
+main(int argc, char *argv[])
+{
+ assert(isnan(lgamma(NAN)));
+ assert(isnan(lgammaf(NAN)));
+
+ signgam = 0;
+ assert(lgamma(-HUGE_VAL) == HUGE_VAL && signgam == 1);
+ signgam = 0;
+ assert(lgammaf(-HUGE_VAL) == HUGE_VAL && signgam == 1);
+
+ signgam = 0;
+ assert(lgamma(HUGE_VAL) == HUGE_VAL && signgam == 1);
+ signgam = 0;
+ assert(lgammaf(HUGE_VAL) == HUGE_VAL && signgam == 1);
+
+ signgam = 0;
+ assert(lgamma(-0.0) == HUGE_VAL && signgam == -1);
+ signgam = 0;
+ assert(lgammaf(-0.0) == HUGE_VAL && signgam == -1);
+
+ signgam = 0;
+ assert(lgamma(0.0) == HUGE_VAL && signgam == 1);
+ signgam = 0;
+ assert(lgammaf(0.0) == HUGE_VAL && signgam == 1);
+
+ signgam = 0;
+ assert(lgamma(1.0) == 0.0 && signgam == 1);
+ signgam = 0;
+ assert(lgammaf(1.0) == 0.0 && signgam == 1);
+
+ signgam = 0;
+ assert(lgamma(3.0) == M_LN2 && signgam == 1);
+ signgam = 0;
+ assert(lgammaf(3.0) == (float)M_LN2 && signgam == 1);
+
+ return (0);
+}