Skip to content
Snippets Groups Projects
Commit d08de500 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

ok

parent 9592721a
No related branches found
No related tags found
No related merge requests found
......@@ -25,8 +25,9 @@ class Range(object):
def __init__(self, *args):
if len(args) == 1:
rs, = args
assert rs[0] in '<('
assert rs[-1] in '>)'
if (rs[0] not in '<(') or (rs[-1] not in '>)'):
raise ValueError('Must start with < or ( and end with ) or >')
lend_inclusive = rs[0] == '<'
rend_inclusive = rs[-1] == '>'
......
......@@ -14,6 +14,10 @@ class TestRange(unittest.TestCase):
def test_str(self):
self.assertEqual(str(Range(-1, 1, True, True)), '<-1;1>')
def test_constructor(self):
self.assertRaises(ValueError, lambda: Range('#2;3>'))
self.assertRaises(ValueError, lambda: Range('(2;3!'))
def test_contains(self):
self.assertFalse(-1 in Range('<-10;-1)'))
self.assertTrue(-10 in Range('<-10;-1)'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment