コード例 #1
0
 def test_get_formatted_intervals_list_from_unsorted_list(self):
     numbers = [3, 2, 1, 4, 8, 7, 9, 17, 12, 13]
     formatted_interval_list = IntervalsExtractor.get_formatted_intervals_list(numbers)
     expected_intervals_list = ["[1-4]", "[7-9]", "[12-13]", "[17]"]
     self.assertEqual(formatted_interval_list, expected_intervals_list)
コード例 #2
0
 def test_get_formatted_intervals_list(self):
     numbers = [1, 2, 3, 4, 7, 8, 9, 12, 13, 17]
     formatted_interval_list = IntervalsExtractor.get_formatted_intervals_list(numbers)
     expected_intervals_list = ["[1-4]", "[7-9]", "[12-13]", "[17]"]
     self.assertEqual(formatted_interval_list, expected_intervals_list)
コード例 #3
0
 def test_given_list_is_not_changed(self):
     original_numbers = [2, 1, 4, 3, 6, 5]
     numbers = [2, 1, 4, 3, 6, 5]
     IntervalsExtractor.extract(numbers)
     self.assertEqual(original_numbers, numbers)
コード例 #4
0
 def test_multiple_intervals_from_unsorted_list(self):
     numbers = [150, 101, 100, 104, 103, 102, 110, 105, 114, 113, 111, 115]
     intervals = IntervalsExtractor.extract(numbers)
     expected_output = "[100-105], [110-111], [113-115], [150]"
     self.assertEqual(expected_output, intervals)
コード例 #5
0
 def test_two_intervals(self):
     numbers = [1, 2, 3, 6, 7, 8]
     intervals = IntervalsExtractor.extract(numbers)
     self.assertEqual("[1-3], [6-8]", intervals)
コード例 #6
0
 def test_single_interval_unsorted(self):
     numbers = [2, 1, 4, 3, 6, 5]
     intervals = IntervalsExtractor.extract(numbers)
     self.assertEqual("[1-6]", intervals)