def test_parse_selection_str_single_range(self): s = '1-3' self.assertEqual([1, 2, 3], parse_selection_str(s, 1, 3)) s = '2-4' self.assertEqual([2, 3, 4], parse_selection_str(s, 1, 5)) s = '2-4' self.assertTrue(parse_selection_str(s, 2, 3) is None) s = '2-4' self.assertTrue(parse_selection_str(s, 3, 5) is None)
def test_parse_selection_str_single_range(self): s = '1-3' self.assertEqual([1, 2, 3], parse_selection_str(s, 1, 3)) s = '2-4' self.assertEqual([2, 3, 4], parse_selection_str(s, 1, 5)) s = '2-4' self.assertTrue(parse_selection_str(s, 2, 3) is None) s = '2-4' self.assertTrue(parse_selection_str(s, 3, 5) is None)
def test_parse_selection_str_single_number(self): s = '1' self.assertEqual([1], parse_selection_str(s, 1, 3)) s = '2' self.assertEqual([2], parse_selection_str(s, 1, 3)) s = '3' self.assertEqual([3], parse_selection_str(s, 1, 3)) s = '-1' self.assertTrue(parse_selection_str(s, 1, 1) is None) s = '1' self.assertTrue(parse_selection_str(s, 2, 2) is None) s = '1' self.assertTrue(parse_selection_str(s, 2, 3) is None)
def test_parse_selection_str_single_number(self): s = '1' self.assertEqual([1], parse_selection_str(s, 1, 3)) s = '2' self.assertEqual([2], parse_selection_str(s, 1, 3)) s = '3' self.assertEqual([3], parse_selection_str(s, 1, 3)) s = '-1' self.assertTrue(parse_selection_str(s, 1, 1) is None) s = '1' self.assertTrue(parse_selection_str(s, 2, 2) is None) s = '1' self.assertTrue(parse_selection_str(s, 2, 3) is None)
def test_parse_selection_str_mix_number_range_spaces(self): s = '1-3, 5,8,10, 11 ,12-14 , 15 -16, 16- 19' self.assertEqual([1, 2, 3, 5, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], parse_selection_str(s, 1, 20))
def test_parse_selection_str_mix_number_range_spaces(self): s = '1-3, 5,8,10, 11 ,12-14 , 15 -16, 16- 19' self.assertEqual([1, 2, 3, 5, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], parse_selection_str(s, 1, 20))