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())
def test_mod(self): """Test that the modulus is found correctly.""" s1 = SerialNumber(12) s2 = SerialNumber(34) self.assertEqual(s1.mod(s2), 12)
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))
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)