Esempio n. 1
0
 def test_pushpop(self):
     heap = XHeap(reversed(ascii_lowercase), key=self.key)
     for u, l in reversed(list(zip(ascii_uppercase, ascii_lowercase))):
         popped_item = heap.pushpop(u)
         heap.check()
         self.assertEqual(l, popped_item)
     self.assertSetEqual(set(ascii_uppercase), set(heap))
Esempio n. 2
0
 def test_remove(self):
     heap = XHeap(reversed(ascii_uppercase), key=self.key)
     for c in reversed(ascii_uppercase):
         wanted = set(heap)
         wanted.remove(c)
         heap.remove(c)
         heap.check()
         self.assertSetEqual(wanted, set(heap))
     self.assertSetEqual(set(), set(heap))
Esempio n. 3
0
 def test_pop(self):
     heap = XHeap(reversed(ascii_uppercase), key=self.key)
     sorted_items = []
     for c in reversed(ascii_uppercase):
         popped_item = heap.pop()
         heap.check()
         self.assertEqual(c, popped_item)
         sorted_items.append(popped_item)
     self.assertSequenceEqual(list(reversed(ascii_uppercase)), sorted_items)
     self.assertSetEqual(set(), set(heap))
Esempio n. 4
0
 def test_push(self):
     heap = XHeap([], key=self.key)
     for c in reversed(ascii_uppercase):
         heap.push(c)
         heap.check()
     self.assertSetEqual(set(ascii_uppercase), set(heap))