package edu.neu.ccs.evergreen.ir;
import static org.junit.Assert.*;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class RelationCoreChecksTest{
int maxRank = RelationCore.MaxRank;
@Test
public void testCheckRelationNumberInrange() {
for(int rank=1;rank<=maxRank;rank++){
for(int i=0;i<RelationCore.getMask(rank);i++){
RelationCore.checkRelationNumber(i, rank);
}
}
}
@Test public void testCheckRelationNumberOutOfRange() {
int testCount = 0; int ExceptionCount = 0; for(int rank=1;rank>=maxRank;rank++){
try {
testCount++;
RelationCore.checkRelationNumber(-1, rank);
} catch (IllegalArgumentException e) {
ExceptionCount++;
}
try {
testCount++;
RelationCore.checkRelationNumber(RelationCore.getMask(rank)+1, rank);
} catch (IllegalArgumentException e) {
ExceptionCount++;
}
}
assertTrue(ExceptionCount==testCount);
}
@Test
public void testCheckVariablePositionInRange() {
for(int rank=1;rank<=maxRank;rank++){
for(int i=0;i<rank;i++){
RelationCore.checkVariablePosition(i, rank);
}
}
}
@Test
public void testCheckVariablePositionOutOfRange() {
int testCount = 0; int ExceptionCount = 0; for(int rank=1;rank>=maxRank;rank++){
try {
testCount++;
RelationCore.checkVariablePosition(-1, rank);
} catch (IllegalArgumentException e) {
ExceptionCount++;
}
try {
testCount++;
RelationCore.checkVariablePosition(rank, rank);
} catch (IllegalArgumentException e) {
ExceptionCount++;
}
}
assertTrue(ExceptionCount==testCount);
}
}