示例#1
0
    def test_take_any(self):
        r = RangeTree(min=0, max=10)
        data = [r.take_any() for i in range(10)]
        self.assertEqual(data, list(range(10)))

        with self.assertRaises(IndexError):
            r.take_any()
示例#2
0
 def test_take_all(self):
     r = RangeTree(min=0, max=255)
     self.assertEqual(r.is_empty(), True)
     for i in range(255):
         self.assertEqual(i, r.take_any())
     self.assertEqual(r.is_empty(), False)
     for i in range(255):
         r.release(i)