* tests/test-ceilf1.c (main): Ensure correct sign of result. * tests/test-ceill.c (main): Likewise. * tests/test-floorf1.c (main): Likewise. * tests/test-floorl.c (main): Likewise. * tests/test-round1.c (main): Likewise. * tests/test-roundf1.c (main): Likewise. * tests/test-roundl.c (main): Likewise. * tests/test-trunc1.c (main): Likewise. * tests/test-truncf1.c (main): Likewise. * tests/test-truncl.c (main): Likewise.
Signed-off-by: Eric Blake <ebl...@redhat.com> --- In my minus_zero cleanups, I noticed that these tests were rather weak; it's possible that there are implementations that return 0.0 when they should be returning -0.0, so let's test that explicitly. The new checks should work even on systems that lack -0.0 (if there are any; I'm not convinced that SGI really lacks -0.0 on MIPS, so much as has a buggy compiler that doesn't expose it well, but I haven't recently logged on to an Irix machine to test this). ChangeLog | 12 ++++++++++++ modules/ceilf-tests | 1 + tests/test-ceilf1.c | 2 ++ tests/test-ceill.c | 2 ++ tests/test-floorf1.c | 2 ++ tests/test-floorl.c | 2 ++ tests/test-round1.c | 2 ++ tests/test-roundf1.c | 2 ++ tests/test-roundl.c | 2 ++ tests/test-trunc1.c | 2 ++ tests/test-truncf1.c | 2 ++ tests/test-truncl.c | 2 ++ 12 files changed, 33 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9aca76a..01a4b39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2010-11-04 Eric Blake <ebl...@redhat.com> + ceil, floor, round, trunc: enhance tests of -0 + * tests/test-ceilf1.c (main): Ensure correct sign of result. + * tests/test-ceill.c (main): Likewise. + * tests/test-floorf1.c (main): Likewise. + * tests/test-floorl.c (main): Likewise. + * tests/test-round1.c (main): Likewise. + * tests/test-roundf1.c (main): Likewise. + * tests/test-roundl.c (main): Likewise. + * tests/test-trunc1.c (main): Likewise. + * tests/test-truncf1.c (main): Likewise. + * tests/test-truncl.c (main): Likewise. + frexp, tests: work around ICC bug with -zero * m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Compute -0.0 in a way that works with more compilers. diff --git a/modules/ceilf-tests b/modules/ceilf-tests index 040fd1b..a0472a7 100644 --- a/modules/ceilf-tests +++ b/modules/ceilf-tests @@ -9,6 +9,7 @@ tests/macros.h Depends-on: float isnanf-nolibm +signbit stdbool stdint diff --git a/tests/test-ceilf1.c b/tests/test-ceilf1.c index 86bb49e..4e38247 100644 --- a/tests/test-ceilf1.c +++ b/tests/test-ceilf1.c @@ -33,7 +33,9 @@ main () { /* Zero. */ ASSERT (ceilf (0.0f) == 0.0f); + ASSERT (!signbit (ceilf (0.0f))); ASSERT (ceilf (minus_zerof) == 0.0f); + ASSERT (!!signbit (minus_zerof) == !!signbit (ceilf (minus_zerof))); /* Positive numbers. */ ASSERT (ceilf (0.3f) == 1.0f); ASSERT (ceilf (0.7f) == 1.0f); diff --git a/tests/test-ceill.c b/tests/test-ceill.c index cac45b7..f627a9e 100644 --- a/tests/test-ceill.c +++ b/tests/test-ceill.c @@ -40,7 +40,9 @@ main () /* Zero. */ ASSERT (ceill (0.0L) == 0.0L); + ASSERT (!signbit (ceill (0.0L))); ASSERT (ceill (minus_zerol) == 0.0L); + ASSERT (!!signbit (minus_zerol) == !!signbit (ceill (minus_zerol))); /* Positive numbers. */ ASSERT (ceill (0.3L) == 1.0L); ASSERT (ceill (0.7L) == 1.0L); diff --git a/tests/test-floorf1.c b/tests/test-floorf1.c index 39261d8..f0f7716 100644 --- a/tests/test-floorf1.c +++ b/tests/test-floorf1.c @@ -33,7 +33,9 @@ main () { /* Zero. */ ASSERT (floorf (0.0f) == 0.0f); + ASSERT (!signbit (floorf (0.0f))); ASSERT (floorf (minus_zerof) == 0.0f); + ASSERT (!!signbit (minus_zerof) == !!signbit (floorf (minus_zerof))); /* Positive numbers. */ ASSERT (floorf (0.3f) == 0.0f); ASSERT (floorf (0.7f) == 0.0f); diff --git a/tests/test-floorl.c b/tests/test-floorl.c index 84717f8..2675a9e 100644 --- a/tests/test-floorl.c +++ b/tests/test-floorl.c @@ -40,7 +40,9 @@ main () /* Zero. */ ASSERT (floorl (0.0L) == 0.0L); + ASSERT (!signbit (floorl (0.0L))); ASSERT (floorl (minus_zerol) == 0.0L); + ASSERT (!!signbit (minus_zerol) == !!signbit (floorl (minus_zerol))); /* Positive numbers. */ ASSERT (floorl (0.3L) == 0.0L); ASSERT (floorl (0.7L) == 0.0L); diff --git a/tests/test-round1.c b/tests/test-round1.c index 86fd1de..4711a74 100644 --- a/tests/test-round1.c +++ b/tests/test-round1.c @@ -35,7 +35,9 @@ main () { /* Zero. */ ASSERT (round (0.0) == 0.0); + ASSERT (!signbit (round (0.0))); ASSERT (round (minus_zerod) == 0.0); + ASSERT (!!signbit (minus_zerod) == !!signbit (round (minus_zerod))); /* Positive numbers. */ ASSERT (round (0.3) == 0.0); ASSERT (round (0.5) == 1.0); diff --git a/tests/test-roundf1.c b/tests/test-roundf1.c index 33609bb..354dcf0 100644 --- a/tests/test-roundf1.c +++ b/tests/test-roundf1.c @@ -35,7 +35,9 @@ main () { /* Zero. */ ASSERT (roundf (0.0f) == 0.0f); + ASSERT (!signbit (roundf (0.0f))); ASSERT (roundf (minus_zerof) == 0.0f); + ASSERT (!!signbit (minus_zerof) == !!signbit (roundf (minus_zerof))); /* Positive numbers. */ ASSERT (roundf (0.3f) == 0.0f); ASSERT (roundf (0.5f) == 1.0f); diff --git a/tests/test-roundl.c b/tests/test-roundl.c index f06db8a..bdb8ddf 100644 --- a/tests/test-roundl.c +++ b/tests/test-roundl.c @@ -42,7 +42,9 @@ main () /* Zero. */ ASSERT (roundl (0.0L) == 0.0L); + ASSERT (!signbit (roundl (0.0L))); ASSERT (roundl (minus_zerol) == 0.0L); + ASSERT (!!signbit (minus_zerol) == !!signbit (roundl (minus_zerol))); /* Positive numbers. */ ASSERT (roundl (0.3L) == 0.0L); ASSERT (roundl (0.5L) == 1.0L); diff --git a/tests/test-trunc1.c b/tests/test-trunc1.c index 69530b8..5587a41 100644 --- a/tests/test-trunc1.c +++ b/tests/test-trunc1.c @@ -33,7 +33,9 @@ main () { /* Zero. */ ASSERT (trunc (0.0) == 0.0); + ASSERT (!signbit (trunc (0.0))); ASSERT (trunc (minus_zerod) == 0.0); + ASSERT (!!signbit (minus_zerod) == !!signbit (trunc (minus_zerod))); /* Positive numbers. */ ASSERT (trunc (0.3) == 0.0); ASSERT (trunc (0.7) == 0.0); diff --git a/tests/test-truncf1.c b/tests/test-truncf1.c index b5f48dd..6953c8b 100644 --- a/tests/test-truncf1.c +++ b/tests/test-truncf1.c @@ -33,7 +33,9 @@ main () { /* Zero. */ ASSERT (truncf (0.0f) == 0.0f); + ASSERT (!signbit (truncf (0.0f))); ASSERT (truncf (minus_zerof) == 0.0f); + ASSERT (!!signbit (minus_zerof) == !!signbit (truncf (minus_zerof))); /* Positive numbers. */ ASSERT (truncf (0.3f) == 0.0f); ASSERT (truncf (0.7f) == 0.0f); diff --git a/tests/test-truncl.c b/tests/test-truncl.c index ab1f444..f2a9644 100644 --- a/tests/test-truncl.c +++ b/tests/test-truncl.c @@ -40,7 +40,9 @@ main () /* Zero. */ ASSERT (truncl (0.0L) == 0.0L); + ASSERT (!signbit (truncl (0.0L))); ASSERT (truncl (minus_zerol) == 0.0L); + ASSERT (!!signbit (minus_zerol) == !!signbit (truncl (minus_zerol))); /* Positive numbers. */ ASSERT (truncl (0.3L) == 0.0L); ASSERT (truncl (0.7L) == 0.0L); -- 1.7.3.2