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)] )
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)