public void ScatteredLongTest(IPrimalityTest p) { foreach (long lTestValue in laScatteredLongPrimes) { Assert.IsTrue(p.IsPrime(lTestValue)); Assert.IsFalse(p.IsComposite(lTestValue)); Assert.IsTrue(p.IsComposite(lTestValue + 1)); Assert.IsFalse(p.IsPrime(lTestValue + 1)); } }
public void TestSmallIntegers(IPrimalityTest p) { for (int i = 0; i <= liPrimes[liPrimes.Count - 1]; i++) { Assert.AreEqual(liPrimes.Contains(i), p.IsPrime(i)); Assert.AreEqual(!liPrimes.Contains(i), p.IsComposite(i)); } }
public void ScatteredBigIntegerTest(IPrimalityTest p) { BigInteger b; for (int i = 0; i < saTestPrimes.Length; i++) { b = BigInteger.Parse(saTestPrimes[i]); Assert.IsTrue(p.IsPrime(b)); Assert.IsFalse(p.IsComposite(b)); Assert.IsFalse(p.IsPrime(b + 1)); Assert.IsTrue(p.IsComposite(b + 1)); } for (int i = 0; i < saTestPseudoPrimes.Length - 1; i++) { b = BigInteger.Parse(saTestPseudoPrimes[i]); Assert.IsTrue(p.IsComposite(b)); } }