public void FindMinTest() { var heap = Enumerable.Range(0, 8).Aggregate(ParingHeap <int> .Empty, (current, i) => ParingHeap <int> .Insert(i, current)); var min = ParingHeap <int> .FindMin(heap); Assert.AreEqual(0, min); }
public void DeleteLotsOfMinsTest() { const int size = 1000; var random = new Random(3456); var heap = ParingHeap <int> .Empty; for (var i = 0; i < size; i++) { heap = ParingHeap <int> .Insert(random.Next(size), heap); } var last = 0; var count = 0; while (!ParingHeap <int> .IsEmpty(heap)) { var next = ParingHeap <int> .FindMin(heap); heap = ParingHeap <int> .DeleteMin(heap); Assert.IsTrue(last <= next); last = next; count++; } Assert.AreEqual(size, count); }
public void FindMinEmptyTest() { var empty = ParingHeap <int> .Empty; AssertThrows <ArgumentNullException>(() => ParingHeap <int> .FindMin(empty)); }