class PermutationTests(unittest.TestCase):
    def setUp(self): self.pm = Permutation(maximumValue=13)
    def test_exceptionForMaxValueNotPrime(self): self.assertRaises(Exception, Permutation, 10)
    def test_initialization(self):
        self.assertTrue(self.pm.a<self.pm.p and self.pm.b<self.pm.p)
        self.assertTrue(self.pm.a%2!=0)
    def test_applyFunction(self):
        l = [self.pm.applyFunction(i) for i in range(self.pm.p)]
        self.assertEqual(sorted(l), range(self.pm.p))
    def test_equality(self):
        pm1 = Permutation(maximumValue=13)
        pm1.a=self.pm.a;pm1.b=self.pm.b
        self.assertEqual(pm1, self.pm)
        self.assertTrue(pm1 in [self.pm])
Exemple #2
0
class PermutationTests(unittest.TestCase):
    def setUp(self):
        self.pm = Permutation(maximumValue=13)

    def test_exceptionForMaxValueNotPrime(self):
        self.assertRaises(Exception, Permutation, 10)

    def test_initialization(self):
        self.assertTrue(self.pm.a < self.pm.p and self.pm.b < self.pm.p)
        self.assertTrue(self.pm.a % 2 != 0)

    def test_applyFunction(self):
        l = [self.pm.applyFunction(i) for i in range(self.pm.p)]
        self.assertEqual(sorted(l), range(self.pm.p))

    def test_equality(self):
        pm1 = Permutation(maximumValue=13)
        pm1.a = self.pm.a
        pm1.b = self.pm.b
        self.assertEqual(pm1, self.pm)
        self.assertTrue(pm1 in [self.pm])
Exemple #3
0
 def setUp(self):
     self.pm = Permutation(maximumValue=13)
Exemple #4
0
 def test_equality(self):
     pm1 = Permutation(maximumValue=13)
     pm1.a = self.pm.a
     pm1.b = self.pm.b
     self.assertEqual(pm1, self.pm)
     self.assertTrue(pm1 in [self.pm])
 def test_equality(self):
     pm1 = Permutation(maximumValue=13)
     pm1.a=self.pm.a;pm1.b=self.pm.b
     self.assertEqual(pm1, self.pm)
     self.assertTrue(pm1 in [self.pm])
 def setUp(self): self.pm = Permutation(maximumValue=13)
 def test_exceptionForMaxValueNotPrime(self): self.assertRaises(Exception, Permutation, 10)