Exemple #1
0
    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");
            }
        }
    }
Exemple #2
0
    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);
        }
    }
Exemple #3
0
 public void Single()
 {
     int[] primes = Primes.GenerateArray(2);
     Assert.AreEqual(1, primes.Length);
     Assert.AreEqual(2, primes[0]);
 }
Exemple #4
0
 public void Prime()
 {
     int[] centArray = Primes.GenerateArray(100);
     Assert.AreEqual(25, centArray.Length);
     Assert.AreEqual(97, centArray[24]);
 }
Exemple #5
0
 public void Zero()
 {
     int[] primes = Primes.GenerateArray(0);
     Assert.AreEqual(0, primes.Length);
 }