public void Lots() { int bound = 10101; int[] primes = Primes.GenerateArray(bound); foreach (int prime in primes) { Assert.IsTrue(IsPrime(prime), "is prime"); } foreach (int prime in primes) { if (IsPrime(prime)) { Assert.IsTrue(Contains(prime, primes), "contains primes"); } else { Assert.IsFalse(Contains(prime, primes), "doesn't contain composites"); } } }
public void Basic() { int[] primes = Primes.GenerateArray(knownPrimes[knownPrimes.Length - 1]); Assert.AreEqual(knownPrimes.Length, primes.Length); int i = 0; foreach (int prime in primes) { Assert.AreEqual(knownPrimes[i++], prime); } }
public void Single() { int[] primes = Primes.GenerateArray(2); Assert.AreEqual(1, primes.Length); Assert.AreEqual(2, primes[0]); }
public void Prime() { int[] centArray = Primes.GenerateArray(100); Assert.AreEqual(25, centArray.Length); Assert.AreEqual(97, centArray[24]); }
public void Zero() { int[] primes = Primes.GenerateArray(0); Assert.AreEqual(0, primes.Length); }