File: test_I_minus.cc

package info (click to toggle)
cln 0.98-7.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 12,188 kB
  • ctags: 15,282
  • sloc: cpp: 71,545; ansic: 12,015; asm: 8,431; sh: 3,159; makefile: 886; lisp: 64
file content (27 lines) | stat: -rw-r--r-- 584 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
#include "test_I.h"

int test_I_minus (int iterations)
{
	int error = 0;
	int i;
	// Check anti-commutativity.
	for (i = iterations; i > 0; i--) {
		cl_I a = testrandom_I();
		cl_I b = testrandom_I();
		ASSERT2((a-b) + (b-a) == 0, a,b);
	}
	// Check associativity.
	for (i = iterations; i > 0; i--) {
		cl_I a = testrandom_I();
		cl_I b = testrandom_I();
		cl_I c = testrandom_I();
		ASSERT3(a-(b-c) == c-(b-a), a,b,c);
	}
	// Check special case 0.
	for (i = iterations; i > 0; i--) {
		cl_I a = testrandom_I();
		ASSERT1(a-0 == a, a);
		ASSERT1(0-(0-a) == a, a);
	}
	return error;
}