示例#1
0
    def test_separate(self):
        interval_1 = Interval(2, 3, is_start_inclusive=True)  # [2, 3)
        interval_2 = Interval(0, 1)  # (0, 1)

        union = Interval.union(interval_1, interval_2)  # Two intervals

        self.assertEqual(len(union.intervals), 2)
示例#2
0
    def test_almost_overlapping(self):
        interval_1 = Interval(1, 3, is_end_inclusive=True)  # (1, 3]
        interval_2 = Interval(0, 1, is_end_inclusive=True)  # (0, 1]

        union = Interval.union(interval_1, interval_2)  # (0, 3]

        self.assertEqual(len(union.intervals), 1)
        self.assertEqual(union.intervals[0].start, 0)
        self.assertEqual(union.intervals[0].end, 3)
        self.assertFalse(union.intervals[0].is_start_inclusive)
        self.assertTrue(union.intervals[0].is_end_inclusive)
示例#3
0
    def test_overlapping(self):

        interval_1 = Interval(1, 3, is_end_inclusive=True)  # (1, 3]
        interval_2 = Interval(2, 5)  # (2, 5)

        union = Interval.union(interval_1, interval_2)  # (1, 5)

        self.assertEqual(len(union.intervals), 1)
        self.assertEqual(union.intervals[0].start, 1)
        self.assertEqual(union.intervals[0].end, 5)
        self.assertFalse(union.intervals[0].is_start_inclusive)
        self.assertFalse(union.intervals[0].is_end_inclusive)