]> www.ginac.de Git - cln.git/blob - tests/test_I_logbitp.cc
Enable modifying operators by default.
[cln.git] / tests / test_I_logbitp.cc
1 #include "test_I.h"
2
3 int test_I_logbitp (int iterations)
4 {
5         int error = 0;
6         int i;
7         // Check against ash and oddp.
8         for (i = iterations; i > 0; i--) {
9                 uintL a = random32() % 1024;
10                 cl_I b = testrandom_I();
11                 ASSERT2(logbitp(a,b) == oddp(ash(b,-(sintL)a)), a,b);
12         }
13         // Check against ash and logand.
14         for (i = iterations; i > 0; i--) {
15                 uintL a = random32() % 1024;
16                 cl_I b = testrandom_I();
17                 ASSERT2(logbitp(a,b) == !zerop(logand(b,ash(1,(sintL)a))), a,b);
18         }
19         // Check against each other.
20         for (i = iterations; i > 0; i--) {
21                 uintL a = random32() % 1024;
22                 cl_I b = testrandom_I();
23                 ASSERT2(logbitp((cl_I)a,b) == logbitp(a,b), a,b);
24         }
25         return error;
26 }