Esempio n. 1
0
        public void FindPrimes_WhenMaxIsComposite_ThenMaxExclusive()
        {
            // when
            IEnumerable <int> result = Primes.FindPrimes(67);

            // then
            result.Should().Equal(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61);
        }
Esempio n. 2
0
        public void FindPrimes_WhenMaxIsTwo_ThenEmpty()
        {
            // when
            IEnumerable <int> result = Primes.FindPrimes(2);

            // then
            result.Should().BeEmpty();
        }
Esempio n. 3
0
        public void TestMiller_WhenComposite2_ThenFalse()
        {
            // when
            bool result = Primes.TestMiller(1105);

            // then
            result.Should().BeFalse();
        }
Esempio n. 4
0
        public void TestMiller_WhenPrime_ThenTrue()
        {
            // when
            bool result = Primes.TestMiller(1013);

            // then
            result.Should().BeTrue();
        }
Esempio n. 5
0
        public void TestFermat_WhenCarmichaelNumber_ThenFalse()
        {
            // when
            bool result = Primes.TestFermat(1105);  // 1105 = 5 * 13 * 17 is a Carmichael number

            // then
            result.Should().BeFalse();
        }
Esempio n. 6
0
        public void TestMiller_WhenOne_ThenFalse()
        {
            // when
            bool result = Primes.TestMiller(1);

            // then
            result.Should().BeFalse();
        }
Esempio n. 7
0
        public void TestFermat_WhenComposite_ThenFalse()
        {
            // when
            bool result = Primes.TestFermat(1001);

            // then
            result.Should().BeFalse();
        }
Esempio n. 8
0
        public void TestFermat_WhenTwo_ThenTrue()
        {
            // when
            bool result = Primes.TestFermat(2);

            // then
            result.Should().BeTrue();
        }
Esempio n. 9
0
        public void FindPrimes_WhenMinGreaterThanMax_ThenEmpty()
        {
            // when
            IEnumerable <int> result = Primes.FindPrimes(100, 30);

            // then
            result.Should().BeEmpty();
        }
Esempio n. 10
0
        public void TestFermat_WhenZero_ThenFalse()
        {
            // when
            bool result = Primes.TestFermat(0);

            // then
            result.Should().BeFalse();
        }
Esempio n. 11
0
        public void FindPrimes_WhenMinEqualsMaxAndComposite_ThenEmpty()
        {
            // when
            IEnumerable <int> result = Primes.FindPrimes(91, 91);

            // then
            result.Should().BeEmpty();
        }
Esempio n. 12
0
        public void FindPrimes_WhenMaxIsComposite_ThenAllPrimes()
        {
            // when
            IEnumerable <int> result = Primes.FindPrimes(100);

            // then
            result.Should().Equal(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
                                  61, 67, 71, 73, 79, 83, 89, 97);
        }
Esempio n. 13
0
        public void FindPrimes_WhenSingleArgument_ThenMinIsZero()
        {
            // when
            IEnumerable <int> result1 = Primes.FindPrimes(100);
            IEnumerable <int> result2 = Primes.FindPrimes(0, 100);

            // then
            result1.Should().Equal(result2);
        }
Esempio n. 14
0
        public void FindPrimes_WhenMinAndMaxArePrimes_ThenMinInclusiveAndMaxExclusive()
        {
            // when
            IEnumerable <int> result = Primes.FindPrimes(137, 317);

            // then
            result.Should().Equal(137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197,
                                  199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271,
                                  277, 281, 283, 293, 307, 311, 313);
        }
Esempio n. 15
0
        public void FindPrimes_WhenMinIsLessThanSquareRootOfMax_ThenPrimesBetween()
        {
            // when
            IEnumerable <int> result = Primes.FindPrimes(5, 150);

            // then
            result.Should().Equal(5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
                                  71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137,
                                  139, 149);
        }
Esempio n. 16
0
        public void FindPrimes_WhenRange_ThenPrimesBetween()
        {
            // when
            IEnumerable <int> result = Primes.FindPrimes(30, 200);

            // then
            result.Should().Equal(31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101,
                                  103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
                                  173, 179, 181, 191, 193, 197, 199);
        }