]> www.ginac.de Git - cln.git/blob - tests/test_I_gcd.cc
* Fix typo.
[cln.git] / tests / test_I_gcd.cc
1 #include "test_I.h"
2
3 int test_I_gcd (int iterations)
4 {
5         int error = 0;
6         int i;
7         // Check commutativity.
8         for (i = iterations; i > 0; i--) {
9                 cl_I a = testrandom_I();
10                 cl_I b = testrandom_I();
11                 ASSERT2(gcd(a,b) == gcd(b,a), a,b);
12         }
13         // Check some axioms.
14         for (i = iterations; i > 0; i--) {
15                 cl_I a = testrandom_I();
16                 cl_I b = testrandom_I();
17                 cl_I g = gcd(a,b);
18                 if (g > 1) {
19                         ASSERT2(mod(a,g) == 0, a,b);
20                         ASSERT2(mod(b,g) == 0, a,b);
21                         ASSERT2(gcd(exquo(a,g),exquo(b,g)) == 1, a,b);
22                 }
23                 cl_I c = testrandom_I();
24                 ASSERT3(gcd(a+b*c,b) == g, a,b,c);
25         }
26         return error;
27 }