public void DeleteLotsOfMinsTest() { const int size = 1000; var random = new Random(3456); var heap = LazyParingHeap <int> .Empty; for (var i = 0; i < size; i++) { heap = LazyParingHeap <int> .Insert(random.Next(size), heap); } var last = 0; var count = 0; while (!LazyParingHeap <int> .IsEmpty(heap)) { var next = LazyParingHeap <int> .FindMin(heap); heap = LazyParingHeap <int> .DeleteMin(heap); Assert.IsTrue(last <= next); last = next; count++; } Assert.AreEqual(size, count); }
public void DeleteMinTest() { var heap = Enumerable.Range(0, 8).Aggregate(LazyParingHeap <int> .Empty, (current, i) => LazyParingHeap <int> .Insert(i, current)); heap = LazyParingHeap <int> .DeleteMin(heap); Assert.AreEqual("[1; [2; [3; [4, [5; [6, [7]]]]]]]", DumpHeap(heap, true)); }
public void DeleteMinEmptyTest() { var empty = LazyParingHeap <int> .Empty; AssertThrows <ArgumentNullException>(() => LazyParingHeap <int> .DeleteMin(empty)); }