summaryrefslogtreecommitdiff
path: root/tests/tcmp_ui.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2010-09-01 09:19:43 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2010-09-01 09:19:43 +0000
commit00bbb908220a0ea8ec602e2a60dfc6acbbda0163 (patch)
treee0832ff6f9bf30ace560c9a7e0256c128e7842b6 /tests/tcmp_ui.c
parentc0a3d2efcda87b48f8ded2e02d8bca59c61394db (diff)
downloadmpfr-00bbb908220a0ea8ec602e2a60dfc6acbbda0163.tar.gz
[tests/tcmp_ui.c] Added side-effect tests similar to those in tset_si.c,
showing a bug in the mpfr_cmp_ui and mpfr_cmp_si macros. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@7115 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tcmp_ui.c')
-rw-r--r--tests/tcmp_ui.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/tcmp_ui.c b/tests/tcmp_ui.c
index 422ae7507..c29979b10 100644
--- a/tests/tcmp_ui.c
+++ b/tests/tcmp_ui.c
@@ -172,6 +172,42 @@ check_macros (void)
mpfr_clear (x);
}
+/* Bug in r7114 */
+static void
+test_macros (void)
+{
+ mpfr_t x[3];
+ mpfr_ptr p;
+
+ mpfr_inits (x[0], x[1], x[2], (mpfr_ptr) 0);
+ mpfr_set_ui (x[0], 0, MPFR_RNDN);
+ p = x[0];
+ if (mpfr_cmp_ui (p++, 0) != 0)
+ {
+ printf ("Error in mpfr_cmp_ui macro: result should be 0.\n");
+ exit (1);
+ }
+ if (p != x[1])
+ {
+ printf ("Error in mpfr_cmp_ui macro: p - x[0] = %d (expecting 1)\n",
+ (int) (p - x[0]));
+ exit (1);
+ }
+ p = x[0];
+ if (mpfr_cmp_si (p++, 0) != 0)
+ {
+ printf ("Error in mpfr_cmp_si macro: result should be 0.\n");
+ exit (1);
+ }
+ if (p != x[1])
+ {
+ printf ("Error in mpfr_cmp_si macro: p - x[0] = %d (expecting 1)\n",
+ (int) (p - x[0]));
+ exit (1);
+ }
+ mpfr_clears (x[0], x[1], x[2], (mpfr_ptr) 0);
+}
+
int
main (void)
{
@@ -301,6 +337,7 @@ main (void)
check_nan ();
check_macros ();
+ test_macros ();
tests_end_mpfr ();
return 0;