Пример #1
0
 def test_binary_11_is_decimal_3(self):
     self.assertEqual(parse_binary("11"), 3)
Пример #2
0
 def test_binary_10001101000_is_decimal_1128(self):
     self.assertEqual(1128, parse_binary("10001101000"))
Пример #3
0
 def test_binary_1_is_decimal_1(self):
     self.assertEqual(parse_binary("1"), 1)
Пример #4
0
 def test_invalid_binary_numbers_with_text(self):
     with self.assertRaisesWithMessage(ValueError):
         parse_binary("10nope")
Пример #5
0
 def test_invalid_binary_number_not_base2(self):
     with self.assertRaisesWithMessage(ValueError):
         parse_binary("102011")
Пример #6
0
 def test_binary_11010_is_decimal_26(self):
     self.assertEqual(parse_binary("11010"), 26)
Пример #7
0
 def test_invalid_binary_text_only(self):
     with self.assertRaisesWithMessage(ValueError):
         parse_binary("carrot")
Пример #8
0
 def test_binary_1_is_decimal_1(self):
     self.assertEqual(1, parse_binary("1"))
Пример #9
0
 def test_binary_10_is_decimal_2(self):
     self.assertEqual(2, parse_binary("10"))
Пример #10
0
 def test_invalid_binary_number_not_base2(self):
     with self.assertRaises(ValueError) as err:
         parse_binary("102011")
     self.assertEqual(type(err.exception), ValueError)
     self.assertEqual(err.exception.args[0],
                      "Invalid binary literal: 102011")
Пример #11
0
 def test_invalid_binary_text_with_numbers(self):
     with self.assertRaises(ValueError) as err:
         parse_binary("nope10")
     self.assertEqual(type(err.exception), ValueError)
     self.assertEqual(err.exception.args[0],
                      "Invalid binary literal: nope10")
Пример #12
0
 def test_invalid_binary_text_only(self):
     with self.assertRaises(ValueError) as err:
         parse_binary("carrot")
     self.assertEqual(type(err.exception), ValueError)
     self.assertEqual(err.exception.args[0],
                      "Invalid binary literal: carrot")
Пример #13
0
 def test_invalid_binary_text_with_numbers(self):
     with self.assertRaisesWithMessage(ValueError):
         parse_binary("nope10")
Пример #14
0
 def test_invalid_binary_numbers_with_text(self):
     with self.assertRaisesWithMessage(ValueError):
         parse_binary("10nope")
Пример #15
0
 def test_binary_100_is_decimal_4(self):
     self.assertEqual(parse_binary("100"), 4)
Пример #16
0
 def test_binary_11_is_decimal_3(self):
     self.assertEqual(3, parse_binary("11"))
Пример #17
0
 def test_binary_1001_is_decimal_9(self):
     self.assertEqual(parse_binary("1001"), 9)
Пример #18
0
 def test_binary_100_is_decimal_4(self):
     self.assertEqual(4, parse_binary("100"))
Пример #19
0
 def test_binary_10001101000_is_decimal_1128(self):
     self.assertEqual(parse_binary("10001101000"), 1128)
Пример #20
0
 def test_binary_1001_is_decimal_9(self):
     self.assertEqual(9, parse_binary("1001"))
Пример #21
0
 def test_invalid_binary_number_not_base2(self):
     with self.assertRaisesWithMessage(ValueError):
         parse_binary("102011")
Пример #22
0
 def test_binary_11010_is_decimal_26(self):
     self.assertEqual(26, parse_binary("11010"))
Пример #23
0
 def test_invalid_binary_text_with_numbers(self):
     with self.assertRaisesWithMessage(ValueError):
         parse_binary("nope10")
Пример #24
0
 def test_invalid_binary_text_only(self):
     with self.assertRaisesWithMessage(ValueError):
         parse_binary("carrot")