コード例 #1
0
 def test_merge(self):
     interval_list = [[1, 3], [2, 6], [8, 10], [15, 18]]
     intervals = [Interval(i[0], i[1]) for i in interval_list]
     merged_intervals = Interval.merge(intervals)
     self.assertEqual(
         merged_intervals, [Interval(1, 6), Interval(8, 10), Interval(15, 18)]
     )
コード例 #2
0
 def test_Interval(self):
     interval = Interval(1, 3)
     self.assertTrue(1 in interval)
     self.assertTrue(3 in interval)
     self.assertFalse(4 in interval)
     self.assertEqual(list(interval), [1, 2, 3])
     self.assertEqual(len(interval), 3)
コード例 #3
0
ファイル: test_array.py プロジェクト: Danawill/algorithms
 def test_merge(self):
     interval_list = [[1, 3], [2, 6], [8, 10], [15, 18]]
     intervals = [Interval(i[0], i[1]) for i in interval_list]
     merged_intervals = Interval.merge(intervals)
     self.assertEqual(
         merged_intervals,
         [Interval(1, 6), Interval(8, 10), Interval(15, 18)]
     )