Exemplo n.º 1
0
        public void CountPrimeNumbersTest()
        {
            // See https://en.wikipedia.org/wiki/Prime_number_theorem
            // or https://www.michael-holzapfel.de/themen/primzahlen/pz-anzahl.htm

            Assert.AreEqual(4, Primes.CountPrimeNumbers(1, 10));
            Assert.AreEqual(25, Primes.CountPrimeNumbers(1, 100));
            Assert.AreEqual(168, Primes.CountPrimeNumbers(1, 1000));
            Assert.AreEqual(1229, Primes.CountPrimeNumbers(1, 10000));
            Assert.AreEqual(9592, Primes.CountPrimeNumbers(1, 100000));
        }
Exemplo n.º 2
0
        public void ProgressReportingTest()
        {
            int callCount = 0;

            Primes.Progress += (percent) => ++ callCount;

            Primes.CountPrimeNumbers(1, 10);
            Primes.CountPrimeNumbers(1, 27389);

            // Calls for percent 10%, 20%, ... 100%
            Assert.AreEqual(2 * 9, callCount);
        }