Exemple #1
0
 def testRanges(self):
     s = RangeSet()
     s.insert(0, 1)
     s.insert(2, 3)
     self.assertEqual(s.ranges(), [(0, 1), (2, 3)])
     s = RangeSet(4, 2)
     self.assertEqual(list(s), [(0, 2), (4, 0)])
Exemple #2
0
 def testComparisonOperators(self):
     s1 = RangeSet(1)
     s2 = RangeSet(2)
     self.assertNotEqual(s1, s2)
     s1.insert(2)
     s2.insert(1)
     self.assertEqual(s1, s2)
     self.assertTrue(RangeSet(2, 1).contains(RangeSet(3, 4)))
     self.assertTrue(RangeSet(2, 1).contains(3, 4))
     self.assertTrue(RangeSet(2, 1).contains(3))
     self.assertTrue(RangeSet(2, 4).isWithin(RangeSet(1, 5)))
     self.assertTrue(RangeSet(2, 4).isWithin(1, 5))
     self.assertFalse(RangeSet(2, 4).isWithin(3))
     self.assertTrue(RangeSet(2, 4).intersects(RangeSet(3, 5)))
     self.assertTrue(RangeSet(2, 4).intersects(3, 5))
     self.assertTrue(RangeSet(2, 4).intersects(3))
     self.assertTrue(RangeSet(2, 4).isDisjointFrom(RangeSet(6, 8)))
     self.assertTrue(RangeSet(2, 4).isDisjointFrom(6, 8))
     self.assertTrue(RangeSet(2, 4).isDisjointFrom(6))