def test_fail_should_not_accept_none_as_argument(self): with self.assertRaises(ValueError): convert_to_bin(None) with self.assertRaises(ValueError): convert_to_hex(None)
def test_fail_should_not_convert_special_char_str(self): with self.assertRaises(ValueError): convert_to_bin("#$%&/(") with self.assertRaises(ValueError): convert_to_hex("#$%&/(")
def test_fail_should_not_accept_empty_str(self): with self.assertRaises(ValueError): convert_to_bin("") with self.assertRaises(ValueError): convert_to_hex("")
def test_fail_should_not_convert_floating_point_numbers(self): with self.assertRaises(ValueError): convert_to_bin(5.0) with self.assertRaises(ValueError): convert_to_hex(5.0)
def test_fail_should_not_convert_alpha_str(self): with self.assertRaises(ValueError): convert_to_bin("hello") with self.assertRaises(ValueError): convert_to_hex("hello")
def test_fail_should_not_convert_negative_numbers(self): with self.assertRaises(ValueError): convert_to_bin(-1) with self.assertRaises(ValueError): convert_to_hex(-1)
def test_pass_can_convert_large_numbers(self): self.assertEqual("1000000000000000000000000000000000000", convert_to_bin(68719476736)) self.assertEqual("1000000000", convert_to_hex(68719476736))
def test_pass_can_convert_string_with_leading_zeros(self): self.assertEqual("1101", convert_to_bin("0013")) self.assertEqual("D", convert_to_hex("0013"))
def test_pass_can_convert_zero(self): self.assertEqual("0", convert_to_bin(0)) self.assertEqual("0", convert_to_hex(0))
def test_pass_can_convert_positive_integer_number(self): self.assertEqual("11100", convert_to_bin(28)) self.assertEqual("1C", convert_to_hex(28))