package de.viathinksoft.immortal.gen2.math;
import static org.junit.Assert.*;
import java.math.BigInteger;
import org.junit.Test;
import de.viathinksoft.immortal.gen2.math.CRTNotSolveableException;
import de.viathinksoft.immortal.gen2.math.MathUtils2;
import de.viathinksoft.immortal.gen2.math.RemainderNotSmallerThanModulusException;
public class MathUtils2Test {
@Test
public void powTest() {
for (int y=-3; y<0; y++) {
try {
fail();
}
}
for (int y=0; y<=3; y++) {
assertEquals(
x.pow(y),
);
}
}
/**
* @throws CRTNotSolveableException
* @throws RemainderNotSmallerThanModulusException
*/
@Test
public void chineseRemainderTest() throws CRTException {
// 45 2 65 3 -> Rest muss kleiner sein als Modul
try {
x = MathUtils2.
chineseRemainder(new BigInteger("45"),
"3"));
fail();
} catch (RemainderNotSmallerThanModulusException e) {
}
// 1 8 0 125 -> 625
x = MathUtils2
// 1 2 0 4 -> Keine Lösung
try {
x = MathUtils2.
chineseRemainder(new BigInteger("1"),
"4"));
fail();
} catch (CRTNotSolveableException e) {
}
// 1 6 3 8 -> 19
x = MathUtils2.
chineseRemainder(new BigInteger("1"),
// -1 7 -3 8 -> 43
// -1 -7 -3 -8 -> 43
// 1 -7 3 -8 -> 43
}
}