예제 #1
0
 def test_is_odd(self):
     """Test that odd serial numbers are identified."""
     s1 = SerialNumber(12)
     s2 = SerialNumber(27)
     self.assertFalse(s1.is_odd())
     self.assertTrue(s2.is_odd())
예제 #2
0
 def test_mod(self):
     """Test that the modulus is found correctly."""
     s1 = SerialNumber(12)
     s2 = SerialNumber(34)
     self.assertEqual(s1.mod(s2), 12)
예제 #3
0
 def test_test_bit(self):
     """Test that the truth value of a bit is found correctly."""
     s = SerialNumber(12)
     self.assertFalse(s.test_bit(0))
     self.assertTrue(s.test_bit(2))
예제 #4
0
 def test_gcd(self):
     """Test that the greatest common divisor is found correctly."""
     s1 = SerialNumber(12)
     s2 = SerialNumber(34)
     self.assertEqual(s1.gcd(s2), 2)