From 526a5ebad30c5be681eee1904991d1300d7f4635 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Mon, 31 Oct 2005 12:08:13 +0000 Subject: Fixed MPFR_INT_CEIL_LOG2 (in mpfr-impl.h) and __gmpfr_int_ceil_log2 (in int_ceil_log2.c) when the argument is a power of 2, and added a test (new test file tests/tinternals.c). This made a bug appear in div_ui.c and mul_ui.c; fixed that too. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3914 280ebfd0-de03-0410-8827-d642c229c3f4 --- tests/tinternals.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/tinternals.c (limited to 'tests/tinternals.c') diff --git a/tests/tinternals.c b/tests/tinternals.c new file mode 100644 index 000000000..bdfa57207 --- /dev/null +++ b/tests/tinternals.c @@ -0,0 +1,44 @@ +/* tinternals -- Test for internals. + +Copyright 2005 Free Software Foundation. +Contributed by the Spaces project, INRIA Lorraine. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 51 Franklin Place, Fifth Floor, Boston, +MA 02110-1301, USA. */ + +#include + +#define MPFR_NEED_LONGLONG_H +#include "mpfr-test.h" + +int +main (void) +{ + int i; + int val[16] = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 }; + + tests_start_mpfr (); + + for (i = 1; i < 17; i++) + { + MPFR_ASSERTN (MPFR_INT_CEIL_LOG2 (i) == val[i-1]); + MPFR_ASSERTN (MPFR_INT_CEIL_LOG2 (i) == __gmpfr_int_ceil_log2 (i)); + } + + tests_end_mpfr (); + return 0; +} -- cgit v1.2.1