Esempio n. 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)
Esempio n. 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("#$%&/(")
Esempio n. 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("")
Esempio n. 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)
Esempio n. 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")
Esempio n. 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)
Esempio n. 7
0
 def test_pass_can_convert_large_numbers(self):
     self.assertEqual("1000000000000000000000000000000000000",
                      convert_to_bin(68719476736))
     self.assertEqual("1000000000", convert_to_hex(68719476736))
Esempio n. 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"))
Esempio n. 9
0
 def test_pass_can_convert_zero(self):
     self.assertEqual("0", convert_to_bin(0))
     self.assertEqual("0", convert_to_hex(0))
Esempio n. 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))