]> www.ginac.de Git - cln.git/blob - tests/test_MI_plus.cc
Allow 64-bit builds on MacOS X 10.5.
[cln.git] / tests / test_MI_plus.cc
1 #include "test_MI.h"
2
3 int test_MI_plus (int iterations)
4 {
5         int error = 0;
6         int i;
7         // Check commutativity.
8         for (i = iterations; i > 0; i--) {
9                 cl_I m = testrandom_I();
10                 cl_modint_ring R = find_modint_ring(m);
11                 cl_MI a = R->canonhom(testrandom_I());
12                 cl_MI b = R->canonhom(testrandom_I());
13                 ASSERT3(a+b == b+a, m,a,b);
14         }
15         // Check associativity.
16         for (i = iterations; i > 0; i--) {
17                 cl_I m = testrandom_I();
18                 cl_modint_ring R = find_modint_ring(m);
19                 cl_MI a = R->canonhom(testrandom_I());
20                 cl_MI b = R->canonhom(testrandom_I());
21                 cl_MI c = R->canonhom(testrandom_I());
22                 ASSERT4((a+b)+c == a+(b+c), m,a,b,c);
23         }
24         // Check special case 0.
25         for (i = iterations; i > 0; i--) {
26                 cl_I m = testrandom_I();
27                 cl_modint_ring R = find_modint_ring(m);
28                 cl_MI a = R->canonhom(testrandom_I());
29                 cl_MI z = R->zero();
30                 ASSERT2(a+z == a, m,a);
31         }
32         return error;
33 }