def test_intersects_withIntervalsThatDoNotIntersect_shouldReturnFalse( self): for _ in range(1000): # Interval in range [0, 1) a = Interval(random.uniform(0, 1), random.uniform(0, 1)) # Interval in range [1, 1000) b = Interval(random.uniform(1, 1000), random.uniform(1, 1000)) # Interval in range [-1000, -0.1) c = Interval(random.uniform(-0.1, -1000), random.uniform(-0.1, -1000)) self.assertFalse(a.intersects(b)) self.assertFalse(a.intersects(c)) self.assertFalse(b.intersects(c))
def test_intersects_withIntervalsThatDoIntersect_shouldReturnTrue(self): i = Interval(0, 3) for _ in range(1000): a = Interval(random.uniform(1, 2), random.uniform(1, 2)) self.assertTrue(i.intersects(a))