[Gmp-commit] /var/hg/gmp: tests/mpq/reuse.c: avoid copies, but check the format.
mercurial at gmplib.org
mercurial at gmplib.org
Sun May 24 21:29:35 UTC 2015
details: /var/hg/gmp/rev/a2e800b20167
changeset: 16655:a2e800b20167
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sun May 24 23:29:21 2015 +0200
description:
tests/mpq/reuse.c: avoid copies, but check the format.
diffstat:
tests/mpq/reuse.c | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diffs (102 lines):
diff -r 43c78f831b77 -r a2e800b20167 tests/mpq/reuse.c
--- a/tests/mpq/reuse.c Sun May 24 12:21:04 2015 +0200
+++ b/tests/mpq/reuse.c Sun May 24 23:29:21 2015 +0200
@@ -91,7 +91,7 @@
int pass, reps = 100;
mpq_t in1, in2, out1;
unsigned long int randbits, in2i;
- mpq_t res1, res2, res3;
+ mpq_t res1, res2;
gmp_randstate_ptr rands;
tests_start ();
@@ -106,7 +106,6 @@
mpq_init (out1);
mpq_init (res1);
mpq_init (res2);
- mpq_init (res3);
for (pass = 1; pass <= reps; pass++)
{
@@ -152,26 +151,31 @@
randbits >>= 1;
(dss_funcs[i]) (res1, in1, in2);
+ MPQ_CHECK_FORMAT(res1);
mpq_set (out1, in1);
(dss_funcs[i]) (out1, out1, in2);
- mpq_set (res2, out1);
+ MPQ_CHECK_FORMAT(out1);
+
+ if (mpq_cmp (res1, out1) != 0)
+ dump_abort (dss_func_names[i], res1, out1);
mpq_set (out1, in2);
(dss_funcs[i]) (out1, in1, out1);
- mpq_set (res3, out1);
+ MPQ_CHECK_FORMAT(out1);
- if (mpq_cmp (res1, res2) != 0)
- dump_abort (dss_func_names[i], res1, res2);
- if (mpq_cmp (res1, res3) != 0)
- dump_abort (dss_func_names[i], res1, res3);
+ if (mpq_cmp (res1, out1) != 0)
+ dump_abort (dss_func_names[i], res1, out1);
mpq_set (out1, in2);
(dss_funcs[i]) (res1, out1, in2);
+ MPQ_CHECK_FORMAT(res1);
(dss_funcs[i]) (res2, in2, in2);
+ MPQ_CHECK_FORMAT(res2);
(dss_funcs[i]) (out1, out1, out1);
+ MPQ_CHECK_FORMAT(out1);
if (mpq_cmp (res1, res2) != 0)
dump_abort (dss_func_names[i], res1, res2);
@@ -188,13 +192,14 @@
}
randbits >>= 1;
(ds_funcs[i]) (res1, in1);
+ MPQ_CHECK_FORMAT(res1);
mpq_set (out1, in1);
(ds_funcs[i]) (out1, out1);
- mpq_set (res2, out1);
+ MPQ_CHECK_FORMAT(out1);
- if (mpq_cmp (res1, res2) != 0)
- dump_abort (ds_func_names[i], res1, res2);
+ if (mpq_cmp (res1, out1) != 0)
+ dump_abort (ds_func_names[i], res1, out1);
}
in2i = urandom () % 65536;
@@ -208,13 +213,14 @@
randbits >>= 1;
(dsi_funcs[i]) (res1, in1, in2i);
+ MPQ_CHECK_FORMAT(res1);
mpq_set (out1, in1);
(dsi_funcs[i]) (out1, out1, in2i);
- mpq_set (res2, out1);
+ MPQ_CHECK_FORMAT(out1);
- if (mpq_cmp (res1, res2) != 0)
- dump_abort (dsi_func_names[i], res1, res2);
+ if (mpq_cmp (res1, out1) != 0)
+ dump_abort (dsi_func_names[i], res1, out1);
}
}
@@ -224,7 +230,6 @@
mpq_clear (out1);
mpq_clear (res1);
mpq_clear (res2);
- mpq_clear (res3);
tests_end ();
exit (0);
More information about the gmp-commit
mailing list