Ejemplo n.º 1
0
 def test_addComm_cornerCase(self):
     """Tests if testing for commutative addition works for n=1"""
     self.assertTrue(TwistedInt.isAddCommutative(1))
Ejemplo n.º 2
0
 def test_printall1_validTwenty(self):
     """Tests finding the x values where x ⊗ x = 1 when n is 20"""
     self.assertEqual("[]  Total: 0", TwistedInt.printall1(20))
Ejemplo n.º 3
0
 def test_addComm_isValid(self):
     """Tests that addition is commutative for n=5"""
     self.assertTrue(TwistedInt.isAddCommutative(5))
Ejemplo n.º 4
0
 def test_printall1_valid(self):
     """Tests finding the x values where x ⊗ x = 1 when n is 17"""
     self.assertEqual("['5', '10']  Total: 2", TwistedInt.printall1(17))
Ejemplo n.º 5
0
 def test_printall1_validOne(self):
     """Tests finding the x values where x ⊗ x = 1 when n is 1"""
     self.assertEqual("[]  Total: 0", TwistedInt.printall1(1))
Ejemplo n.º 6
0
 def test_init_nAndValueEqual(self):
     """Tests an initialization where the n and value are equal"""
     a = TwistedInt(2, 2)
     self.assertEqual(2, a.value)
     self.assertEqual(2, a.n)
Ejemplo n.º 7
0
 def test_mul_differentN(self):
     """Tests that multiplying twisted ints that have a different n throws an error"""
     a = TwistedInt(2, 5)
     b = TwistedInt(0, 2)
     self.assertRaises(ValueError, TwistedInt.__mul__, a, b)
Ejemplo n.º 8
0
 def test_mul_zeroValue(self):
     """Tests multiplying a twisted int with a valid twisted int of value 0"""
     a = TwistedInt(2, 5)
     b = TwistedInt(0, 5)
     self.assertEqual("<2:5>", str(a * b))
Ejemplo n.º 9
0
 def test_mul_equalValues(self):
     """Tests multiplying two twisted ints that have the same value"""
     a = TwistedInt(3, 5)
     b = TwistedInt(3, 5)
     self.assertEqual("<0:5>", str(a * b))
Ejemplo n.º 10
0
 def test_diff_length(self):
     """Tests the creation of TwistedMatrix with rows of different length"""
     x = [TwistedInt(0, 2), TwistedInt(1, 2)]
     y = [TwistedInt(0, 3), TwistedInt(1, 3), TwistedInt(2, 3)]
     self.assertRaises(ValueError, TwistedMatrix.__init__, self, [x, y])