Skip to content

Commit

Permalink
Merge pull request #274 from behrtam/binary-add-test-invalid-input
Browse files Browse the repository at this point in the history
binary: Expand invalid input tests
  • Loading branch information
behrtam committed Feb 1, 2016
2 parents a9bc2b5 + 0bd10c5 commit cf038f6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions exercises/binary/binary_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


class BinaryTests(unittest.TestCase):

def test_binary_1_is_decimal_1(self):
self.assertEqual(1, parse_binary("1"))

Expand All @@ -31,11 +32,17 @@ def test_binary_11010_is_decimal_26(self):
def test_binary_10001101000_is_decimal_1128(self):
self.assertEqual(1128, parse_binary("10001101000"))

def test_invalid_binary_raises_error(self):
def test_invalid_binary_text_only(self):
self.assertRaises(ValueError, parse_binary, "carrot")

def test_invalid_binary_raises_error_2(self):
def test_invalid_binary_number_not_base2(self):
self.assertRaises(ValueError, parse_binary, "102011")

def test_invalid_binary_numbers_with_text(self):
self.assertRaises(ValueError, parse_binary, "10nope")

def test_invalid_binary_text_with_numbers(self):
self.assertRaises(ValueError, parse_binary, "nope10")

if __name__ == '__main__':
unittest.main()

0 comments on commit cf038f6

Please sign in to comment.