summaryrefslogtreecommitdiff
path: root/mini-gmp/tests
diff options
context:
space:
mode:
authorNiels M?ller <nisse@lysator.liu.se>2019-09-30 23:05:52 +0200
committerNiels M?ller <nisse@lysator.liu.se>2019-09-30 23:05:52 +0200
commitc346d201beefb784c7a835834fe67ab5e322ba6f (patch)
treecea908f74a29d119c84c6069d0acdb41298f5c95 /mini-gmp/tests
parent4181291739edafcb020ac6a15b3d4d834b00aa9d (diff)
downloadgmp-c346d201beefb784c7a835834fe67ab5e322ba6f.tar.gz
mini-gmp: Stricter validity checks for gcdext corner cases.
Diffstat (limited to 'mini-gmp/tests')
-rw-r--r--mini-gmp/tests/t-gcd.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/mini-gmp/tests/t-gcd.c b/mini-gmp/tests/t-gcd.c
index 127800029..64f90f4cf 100644
--- a/mini-gmp/tests/t-gcd.c
+++ b/mini-gmp/tests/t-gcd.c
@@ -41,13 +41,15 @@ gcdext_valid_p (const mpz_t a, const mpz_t b,
if (mpz_sgn (a) == 0)
{
/* Must have g == abs (b). Any value for s is in some sense "correct",
- but it makes sense to require that s == 0. */
- return mpz_cmpabs (g, b) == 0 && mpz_sgn (s) == 0;
+ but it makes sense to require that s == 0, t = sgn (b)*/
+ return mpz_cmpabs (g, b) == 0
+ && mpz_sgn (s) == 0 && mpz_cmp_si (t, mpz_sgn (b)) == 0;
}
else if (mpz_sgn (b) == 0)
{
- /* Must have g == abs (a), s == sign (a) */
- return mpz_cmpabs (g, a) == 0 && mpz_cmp_si (s, mpz_sgn (a)) == 0;
+ /* Must have g == abs (a), s == sign (a), t = 0 */
+ return mpz_cmpabs (g, a) == 0
+ && mpz_cmp_si (s, mpz_sgn (a)) == 0 && mpz_sgn (t) == 0;
}
if (mpz_sgn (g) <= 0)