[Gmp-commit] /var/hg/gmp: mini-gmp: Test also mpz_mul_si, and mpz_ui_sub.
mercurial at gmplib.org
mercurial at gmplib.org
Sun Jan 13 10:52:02 CET 2013
details: /var/hg/gmp/rev/1c86d84a3c18
changeset: 15264:1c86d84a3c18
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sun Jan 13 10:50:16 2013 +0100
description:
mini-gmp: Test also mpz_mul_si, and mpz_ui_sub.
diffstat:
ChangeLog | 3 +++
mini-gmp/tests/t-mul.c | 16 +++++++++++++++-
mini-gmp/tests/t-sub.c | 18 ++++++++++++++++--
3 files changed, 34 insertions(+), 3 deletions(-)
diffs (107 lines):
diff -r f56b9aa645e5 -r 1c86d84a3c18 ChangeLog
--- a/ChangeLog Sat Jan 12 16:36:20 2013 +0100
+++ b/ChangeLog Sun Jan 13 10:50:16 2013 +0100
@@ -15,6 +15,9 @@
* mini-gmp/tests/t-root.c: Use mpz_ui_pow_ui, when base fits an ui.
+ * mini-gmp/tests/t-mul.c: Test also mpz_mul_si.
+ * mini-gmp/tests/t-sub.c: Test also mpz_ui_sub.
+
2013-01-10 Marco Bodrato <bodrato at mail.dm.unipi.it>
* mpz/export.c: Less restrictive ASSERTs.
diff -r f56b9aa645e5 -r 1c86d84a3c18 mini-gmp/tests/t-mul.c
--- a/mini-gmp/tests/t-mul.c Sat Jan 12 16:36:20 2013 +0100
+++ b/mini-gmp/tests/t-mul.c Sun Jan 13 10:50:16 2013 +0100
@@ -38,13 +38,14 @@
main (int argc, char **argv)
{
unsigned i;
- mpz_t a, b, res, ref;
+ mpz_t a, b, res, res_ui, ref;
hex_random_init ();
mpz_init (a);
mpz_init (b);
mpz_init (res);
+ mpz_init (res_ui);
mpz_init (ref);
for (i = 0; i < COUNT; i++)
@@ -60,10 +61,23 @@
dump ("ref", ref);
abort ();
}
+ if (mpz_fits_slong_p (b)) {
+ mpz_mul_si (res_ui, a, mpz_get_si (b));
+ if (mpz_cmp (res_ui, ref))
+ {
+ fprintf (stderr, "mpz_mul_si failed:\n");
+ dump ("a", a);
+ dump ("b", b);
+ dump ("r", res_ui);
+ dump ("ref", ref);
+ abort ();
+ }
+ }
}
mpz_clear (a);
mpz_clear (b);
mpz_clear (res);
+ mpz_clear (res_ui);
mpz_clear (ref);
return 0;
diff -r f56b9aa645e5 -r 1c86d84a3c18 mini-gmp/tests/t-sub.c
--- a/mini-gmp/tests/t-sub.c Sat Jan 12 16:36:20 2013 +0100
+++ b/mini-gmp/tests/t-sub.c Sun Jan 13 10:50:16 2013 +0100
@@ -1,6 +1,6 @@
/*
-Copyright 2012, Free Software Foundation, Inc.
+Copyright 2012, 2013 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite.
@@ -37,13 +37,14 @@
main (int argc, char **argv)
{
unsigned i;
- mpz_t a, b, res, ref;
+ mpz_t a, b, res, res_ui, ref;
hex_random_init ();
mpz_init (a);
mpz_init (b);
mpz_init (res);
+ mpz_init (res_ui);
mpz_init (ref);
for (i = 0; i < COUNT; i++)
@@ -59,10 +60,23 @@
dump ("ref", ref);
abort ();
}
+ if (mpz_fits_ulong_p (a)) {
+ mpz_ui_sub (res_ui, mpz_get_ui (a), b);
+ if (mpz_cmp (res_ui, ref))
+ {
+ fprintf (stderr, "mpz_ui_sub failed:\n");
+ dump ("a", a);
+ dump ("b", b);
+ dump ("r", res_ui);
+ dump ("ref", ref);
+ abort ();
+ }
+ }
}
mpz_clear (a);
mpz_clear (b);
mpz_clear (res);
+ mpz_clear (res_ui);
mpz_clear (ref);
return 0;
More information about the gmp-commit
mailing list