PageRenderTime 33ms CodeModel.GetById 26ms app.highlight 6ms RepoModel.GetById 0ms app.codeStats 0ms

/cln-1.3.2/tests/test_I_logand.cc

#
C++ | 23 lines | 20 code | 1 blank | 2 comment | 6 complexity | a0615b2e314cf5e248deef20d8e71b65 MD5 | raw file
Possible License(s): GPL-2.0
 1#include "test_I.h"
 2
 3int test_I_logand (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(logand(a,b) == logand(b,a), a,b);
12	}
13	// Check against ash and oddp.
14	for (i = iterations; i > 0; i--) {
15		cl_I a = testrandom_I();
16		cl_I b = testrandom_I();
17		ASSERT2(oddp(logand(a,b)) == (oddp(a) & oddp(b)), a,b);
18		sintL c = random32() % 1024;
19		ASSERT3(logand(ash(a,c),ash(b,c)) == ash(logand(a,b),c), a,b,c);
20		ASSERT3(logand(ash(a,-c),ash(b,-c)) == ash(logand(a,b),-c), a,b,c);
21	}
22	return error;
23}