Example #1
0
    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)
Example #2
0
    def test_fail_should_not_convert_special_char_str(self):
        with self.assertRaises(ValueError):
            convert_to_bin("#$%&/(")

        with self.assertRaises(ValueError):
            convert_to_hex("#$%&/(")
Example #3
0
    def test_fail_should_not_accept_empty_str(self):
        with self.assertRaises(ValueError):
            convert_to_bin("")

        with self.assertRaises(ValueError):
            convert_to_hex("")
Example #4
0
    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)
Example #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")
Example #6
0
    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)
Example #7
0
 def test_pass_can_convert_large_numbers(self):
     self.assertEqual("1000000000000000000000000000000000000",
                      convert_to_bin(68719476736))
     self.assertEqual("1000000000", convert_to_hex(68719476736))
Example #8
0
 def test_pass_can_convert_string_with_leading_zeros(self):
     self.assertEqual("1101", convert_to_bin("0013"))
     self.assertEqual("D", convert_to_hex("0013"))
Example #9
0
 def test_pass_can_convert_zero(self):
     self.assertEqual("0", convert_to_bin(0))
     self.assertEqual("0", convert_to_hex(0))
Example #10
0
 def test_pass_can_convert_positive_integer_number(self):
     self.assertEqual("11100", convert_to_bin(28))
     self.assertEqual("1C", convert_to_hex(28))