]> www.ginac.de Git - cln.git/blob - tests/test_I_logtest.cc
Fix typo.
[cln.git] / tests / test_I_logtest.cc
1 #include "test_I.h"
2
3 int test_I_logtest (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(logtest(a,b) == logtest(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                 ASSERT2(!logtest(a,logand(b,lognot(a))), a,b);
18                 ASSERT2(!logtest(logand(b,lognot(a)),a), a,b);
19                 ASSERT2(!logtest(b,logand(a,lognot(b))), a,b);
20                 ASSERT2(!logtest(logand(a,lognot(b)),b), a,b);
21                 if (a != 0)
22                         ASSERT2(logtest(a,logior(a,b)), a,b);
23                 if (b != 0)
24                         ASSERT2(logtest(b,logior(a,b)), a,b);
25         }
26         // Check some special cases, against ash and logbitp.
27         for (i = iterations; i > 0; i--) {
28                 uintL a = random32() % 1024;
29                 cl_I b = testrandom_I();
30                 ASSERT2(logbitp(a,b) == logtest(b,ash(1,(sintL)a)), a,b);
31         }
32         return error;
33 }