def test_empty(self): interval_1 = Interval(1, 3, is_start_inclusive=True) # [1, 3) interval_2 = Interval(0, 1) # (0, 1) intersection = Interval.intersection(interval_1, interval_2) # Empty self.assertEqual(intersection, None)
def test_single_point(self): interval_1 = Interval(1, 3, is_start_inclusive=True) # [1, 3) interval_2 = Interval(0, 1, is_end_inclusive=True) # (0, 1] intersection = Interval.intersection(interval_1, interval_2) # {1} self.assertEqual(intersection.start, 1) self.assertEqual(intersection.end, 1) self.assertTrue(intersection.is_start_inclusive) self.assertTrue(intersection.is_end_inclusive)
def test_ordinary(self): interval_1 = Interval(1, 3, is_end_inclusive=True) # (1, 3] interval_2 = Interval(2, 5) # (2, 5) intersection = Interval.intersection(interval_1, interval_2) # (2, 3] self.assertEqual(intersection.start, 2) self.assertEqual(intersection.end, 3) self.assertFalse(intersection.is_start_inclusive) self.assertTrue(intersection.is_end_inclusive)