# Test Cases for PrimalPy

import unittest
import sys
sys.path.insert(0, '../')


from get_prime_array import get_prime_array
from trial_division import trial_division
from miller_rabin import miller_rabin
from pocklington_lehmer import pocklington_lehmer


class TestGetPrimeArray(unittest.TestCase):

    def setUp(self):
        #Create a prime array using the get_prime_array method
        self.prime_set = get_prime_array( 250000 )
    
    def test_correct(self):
        #Make sure general properties are correct
        self.assertEqual( len(self.prime_set), 22044 )
        self.assertEqual( self.prime_set[22043], 249989 )
        self.assertEqual( self.prime_set[0], 2 )

class TestTrialDivision(unittest.TestCase):
    
    def setUp(self):
        #Use the pre-generated primes to test - we test with all primes <= 200000
        #TODO: don't do this in every test
        self.prime_set = get_prime_array(200000)
        self.not_primes = [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20]

    def test_true(self):
        # Makes sure the test returns true for primes
        for prime in self.prime_set:
            self.assertTrue( trial_division( prime ) )

    def test_false(self):
        #Makes sure the test returns false for non-primes
        for notPrime in self.not_primes:
            self.assertFalse( trial_division( notPrime ) )

class TestMillerRabin(unittest.TestCase):
    
    def setUp(self):
        #Use the pre-generated primes to test - we test with all primes <= 200000
        #TODO: don't do this in every test
        self.prime_set = get_prime_array(5000)
        self.not_primes = [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20]

    def test_true(self):
        # Makes sure the test returns true for primes
        for prime in self.prime_set:
            self.assertTrue( miller_rabin( prime, prime) )

    def test_false(self):
        #Makes sure the test returns false for non-primes
        for notPrime in self.not_primes:
            self.assertFalse( miller_rabin( notPrime, notPrime) )

if __name__ == '__main__':
    unittest.main()
@@ -199,16 +199,62 @@
 r_rabin%0A
+from solovay_strassen import solovay_strassen%0A
 from poc
@@ -2066,16 +2066,707 @@
 Prime) )
+%0A%09%09%09%0Aclass TestSolovayStrassen(unittest.TestCase):%0A    %0A    def setUp(self):%0A        #Use the pre-generated primes to test - we test with all primes %3C= 200000%0A        #TODO: don't do this in every test%0A        self.prime_set = get_prime_array(5000)%0A        self.not_primes = %5B4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20%5D%0A%0A    def test_true(self):%0A        # Makes sure the test returns true for primes%0A        for prime in self.prime_set:%0A            self.assertTrue( solovay_strassen( prime, prime) )%0A%0A    def test_false(self):%0A        #Makes sure the test returns false for non-primes%0A        for notPrime in self.not_primes:%0A            self.assertFalse( solovay_strassen( notPrime, notPrime) )
 %0A%0Aif __n

Test cases for Solovay Strassen