summaryrefslogtreecommitdiff
path: root/regress/lib
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2011-04-10 11:10:10 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2011-04-10 11:10:10 +0000
commit083dfe08c00ebfd13c83b5fda188f99bf4d8e47d (patch)
tree794a940ba2638e485d258bf742fb762a46bb38a0 /regress/lib
parent7e9fc2894839bfba9c526ea573130ac0f2e75844 (diff)
add tests for values zero, -zero; and values close to zero with
-inf/+inf rounding modes.
Diffstat (limited to 'regress/lib')
-rw-r--r--regress/lib/libm/rint/rint.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/regress/lib/libm/rint/rint.c b/regress/lib/libm/rint/rint.c
index edb0baf7348..50c11c7e314 100644
--- a/regress/lib/libm/rint/rint.c
+++ b/regress/lib/libm/rint/rint.c
@@ -1,14 +1,15 @@
-/* $OpenBSD: rint.c,v 1.7 2008/12/09 20:35:13 martynas Exp $ */
+/* $OpenBSD: rint.c,v 1.8 2011/04/10 11:10:09 martynas Exp $ */
/* Written by Michael Shalayeff, 2003, Public domain. */
-#include <err.h>
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <math.h>
+#include <ieeefp.h>
static void
sigfpe(int sig, siginfo_t *si, void *v)
@@ -33,20 +34,26 @@ main(int argc, char *argv[])
sa.sa_flags = SA_SIGINFO;
sigaction(SIGFPE, &sa, NULL);
- if (rint(8.6) != 9.)
- errx(1, "rint");
- if (rintf(8.6F) != 9)
- errx(1, "rintf");
- if (rintl(8.6L) != 9)
- errx(1, "rintl");
- if (lrint(8.6) != 9L)
- errx(1, "lrint");
- if (lrintf(8.6F) != 9L)
- errx(1, "lrintf");
- if (llrint(8.6) != 9LL)
- errx(1, "llrint");
- if (llrintf(8.6F) != 9LL)
- errx(1, "llrintf");
+ assert(rint(8.6) == 9.);
+ assert(rintf(8.6F) == 9);
+ assert(rintl(8.6L) == 9);
+ assert(lrint(8.6) == 9L);
+ assert(lrintf(8.6F) == 9L);
+ assert(llrint(8.6) == 9LL);
+ assert(llrintf(8.6F) == 9LL);
+
+ assert(lrint(0.0) == 0L);
+ assert(lrintf(0.0) == 0L);
+ assert(lrint(-0.0) == 0L);
+ assert(lrintf(-0.0) == 0L);
+
+ fpsetround(FP_RM);
+ assert(lrint(-0.1) == -1L);
+ assert(lrintf(-0.1) == -1L);
+
+ fpsetround(FP_RP);
+ assert(lrint(0.1) == 1L);
+ assert(lrintf(0.1) == 1L);
exit(0);
}