def testRemove(self): d = iter(util.IntervalDifferential([3, 5], 10)) self.assertEquals(d.next(), (3, 0)) self.assertEquals(d.next(), (2, 1)) self.assertEquals(d.next(), (1, 0)) d.removeInterval(3) self.assertEquals(d.next(), (4, 0)) self.assertEquals(d.next(), (5, 0)) d.removeInterval(5) self.assertEquals(d.next(), (10, None)) self.assertRaises(ValueError, d.removeInterval, 10)
def testInsert(self): d = iter(util.IntervalDifferential([], 10)) self.assertEquals(d.next(), (10, None)) d.addInterval(3) self.assertEquals(d.next(), (3, 0)) self.assertEquals(d.next(), (3, 0)) d.addInterval(6) self.assertEquals(d.next(), (3, 0)) self.assertEquals(d.next(), (3, 0)) self.assertEquals(d.next(), (0, 1)) self.assertEquals(d.next(), (3, 0)) self.assertEquals(d.next(), (3, 0)) self.assertEquals(d.next(), (0, 1))
def testPair(self): d = iter(util.IntervalDifferential([5, 7], 10)) for i in range(100): self.assertEquals(d.next(), (5, 0)) self.assertEquals(d.next(), (2, 1)) self.assertEquals(d.next(), (3, 0)) self.assertEquals(d.next(), (4, 1)) self.assertEquals(d.next(), (1, 0)) self.assertEquals(d.next(), (5, 0)) self.assertEquals(d.next(), (1, 1)) self.assertEquals(d.next(), (4, 0)) self.assertEquals(d.next(), (3, 1)) self.assertEquals(d.next(), (2, 0)) self.assertEquals(d.next(), (5, 0)) self.assertEquals(d.next(), (0, 1))
def testTriple(self): d = iter(util.IntervalDifferential([2, 4, 5], 10)) for i in range(100): self.assertEquals(d.next(), (2, 0)) self.assertEquals(d.next(), (2, 0)) self.assertEquals(d.next(), (0, 1)) self.assertEquals(d.next(), (1, 2)) self.assertEquals(d.next(), (1, 0)) self.assertEquals(d.next(), (2, 0)) self.assertEquals(d.next(), (0, 1)) self.assertEquals(d.next(), (2, 0)) self.assertEquals(d.next(), (0, 2)) self.assertEquals(d.next(), (2, 0)) self.assertEquals(d.next(), (0, 1)) self.assertEquals(d.next(), (2, 0)) self.assertEquals(d.next(), (1, 2)) self.assertEquals(d.next(), (1, 0)) self.assertEquals(d.next(), (0, 1)) self.assertEquals(d.next(), (2, 0)) self.assertEquals(d.next(), (2, 0)) self.assertEquals(d.next(), (0, 1)) self.assertEquals(d.next(), (0, 2))
def testSingle(self): d = iter(util.IntervalDifferential([5], 10)) for i in range(100): self.assertEquals(d.next(), (5, 0))
def testDefault(self): d = iter(util.IntervalDifferential([], 10)) for i in range(100): self.assertEquals(d.next(), (10, None))