File: test_I_logtest.cc

package info (click to toggle)
cln 1.3.4-4
  • links: PTS
  • area: main
  • in suites: buster
  • size: 10,724 kB
  • sloc: cpp: 80,930; sh: 11,982; ansic: 3,278; makefile: 1,313
file content (33 lines) | stat: -rw-r--r-- 898 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "test_I.h"

int test_I_logtest (int iterations)
{
	int error = 0;
	int i;
	// Check commutativity.
	for (i = iterations; i > 0; i--) {
		cl_I a = testrandom_I();
		cl_I b = testrandom_I();
		ASSERT2(logtest(a,b) == logtest(b,a), a,b);
	}
	// Check some axioms.
	for (i = iterations; i > 0; i--) {
		cl_I a = testrandom_I();
		cl_I b = testrandom_I();
		ASSERT2(!logtest(a,logand(b,lognot(a))), a,b);
		ASSERT2(!logtest(logand(b,lognot(a)),a), a,b);
		ASSERT2(!logtest(b,logand(a,lognot(b))), a,b);
		ASSERT2(!logtest(logand(a,lognot(b)),b), a,b);
		if (a != 0)
			ASSERT2(logtest(a,logior(a,b)), a,b);
		if (b != 0)
			ASSERT2(logtest(b,logior(a,b)), a,b);
	}
	// Check some special cases, against ash and logbitp.
	for (i = iterations; i > 0; i--) {
		uintL a = random32() % 1024;
		cl_I b = testrandom_I();
		ASSERT2(logbitp(a,b) == logtest(b,ash(1,(sintL)a)), a,b);
	}
	return error;
}