diff options
author | Martynas Venckus <martynas@cvs.openbsd.org> | 2011-05-28 22:38:07 +0000 |
---|---|---|
committer | Martynas Venckus <martynas@cvs.openbsd.org> | 2011-05-28 22:38:07 +0000 |
commit | 3b99ec924ad8470a83a527aca1ba175e53a2438d (patch) | |
tree | e485c5bb795203478b7f7ae56c577961df5c9b80 /regress/lib | |
parent | 2a576aeab43e6ee183e4f7482433a23395f4ae2f (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/Makefile | 7 | ||||
-rw-r--r-- | regress/lib/libm/lgamma/lgamma.c | 47 |
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); +} |