Delete FastPowerTest.java___jb_tmp___

This commit is contained in:
Libin Yang 2019-05-10 15:42:55 +08:00 committed by GitHub
parent 1041b02e6b
commit cac1b0b4c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,35 +0,0 @@
package src.test.java.com.others;
import org.junit.Test;
import src.main.java.com.others.FastPower;
import java.math.BigInteger;
import static org.junit.Assert.*;
public class FastPowerTest {
@Test
void testLong(long n, long k, long m) {
long result = FastPower.calculate(n, k, m);
assertEquals(result, BigInteger.valueOf(n).modPow(BigInteger.valueOf(k), BigInteger.valueOf(m)).longValue());
}
@Test
void testBigInteger(BigInteger n, BigInteger k, BigInteger m) {
BigInteger result = FastPower.calculate(n, k, m);
assertEquals(result, n.modPow(k, m));
}
@Test
public void test() {
testLong(2, 2, 10);
testLong(100, 1000, 20);
testLong(123456, 123456789, 234);
testBigInteger(BigInteger.TEN, BigInteger.TEN, BigInteger.valueOf(4));
testBigInteger(new BigInteger("123456"), new BigInteger("123456789"), new BigInteger("234"));
testBigInteger(new BigInteger("123456789101112"), new BigInteger("12345678910111213"), new BigInteger("567890"));
}
}