# HG changeset patch # User Bruno Haible # Date 1330336502 -3600 # Node ID 3a58d2c88e2e0fe282e157da39aa16dedb5a7013 # Parent 5d99cc3818ef25e98b6ac5960d158abec4034bc0 Tests for module 'rintf-ieee'. * modules/rintf-ieee-tests: New file. * tests/test-rintf-ieee.c: New file. * tests/test-rint-ieee.h: New file. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2012-02-27 Bruno Haible + Tests for module 'rintf-ieee'. + * modules/rintf-ieee-tests: New file. + * tests/test-rintf-ieee.c: New file. + * tests/test-rint-ieee.h: New file. + New module 'rintf-ieee'. * modules/rintf-ieee: New file. diff --git a/modules/rintf-ieee-tests b/modules/rintf-ieee-tests new file mode 100644 --- /dev/null +++ b/modules/rintf-ieee-tests @@ -0,0 +1,19 @@ +Files: +tests/test-rintf-ieee.c +tests/test-rint-ieee.h +tests/minus-zero.h +tests/infinity.h +tests/nan.h +tests/macros.h + +Depends-on: +isnanf-nolibm +float +signbit + +configure.ac: + +Makefile.am: +TESTS += test-rintf-ieee +check_PROGRAMS += test-rintf-ieee +test_rintf_ieee_LDADD = $(LDADD) @RINTF_LIBM@ diff --git a/tests/test-rint-ieee.h b/tests/test-rint-ieee.h new file mode 100644 --- /dev/null +++ b/tests/test-rint-ieee.h @@ -0,0 +1,40 @@ +/* Test of rint*() function family. + Copyright (C) 2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +static void +test_function (void) +{ + /* [MX] shaded specification in POSIX. */ + + /* NaN. */ + ASSERT (ISNAN (RINT (NAN))); + + /* Signed zero. */ + { + DOUBLE y = RINT (L_(0.0)); + ASSERT (y == L_(0.0)); + ASSERT (!signbit (y)); + } + { + DOUBLE y = RINT (MINUS_ZERO); + ASSERT (y == L_(0.0)); + ASSERT (!!signbit (y) == !!signbit (MINUS_ZERO)); + } + + /* Infinity. */ + ASSERT (RINT (INFINITY) == INFINITY); + ASSERT (RINT (- INFINITY) == - INFINITY); +} diff --git a/tests/test-rintf-ieee.c b/tests/test-rintf-ieee.c new file mode 100644 --- /dev/null +++ b/tests/test-rintf-ieee.c @@ -0,0 +1,45 @@ +/* Test of rintf() function. + Copyright (C) 2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#include + +#include "isnanf-nolibm.h" +#include "minus-zero.h" +#include "infinity.h" +#include "nan.h" +#include "macros.h" + +#undef INFINITY +#undef NAN + +#define DOUBLE float +#define ISNAN isnanf +#define INFINITY Infinityf () +#define NAN NaNf () +#define L_(literal) literal##f +#define MINUS_ZERO minus_zerof +#define RINT rintf +#include "test-rint-ieee.h" + +int +main () +{ + test_function (); + + return 0; +}