summaryrefslogtreecommitdiff
path: root/tests/tinternals.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2005-10-31 12:08:13 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2005-10-31 12:08:13 +0000
commit526a5ebad30c5be681eee1904991d1300d7f4635 (patch)
tree2e36dd714c323f30d71ac73770b48febaf5cdd6a /tests/tinternals.c
parent385dd2a5145031a48b33efbfc6b389cd889eb911 (diff)
downloadmpfr-526a5ebad30c5be681eee1904991d1300d7f4635.tar.gz
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
Diffstat (limited to 'tests/tinternals.c')
-rw-r--r--tests/tinternals.c44
1 files changed, 44 insertions, 0 deletions
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 <stdio.h>
+
+#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;
+}