public void ExtractMinimum_SingleElement_ReturnsElement() { var heap = new PairingHeap <int>(); heap.Insert(42); Assert.That(heap.ExtractMinimum(), Is.EqualTo(42)); }
public void ExtractMinimum_SingleElement_RemovesElement() { var heap = new PairingHeap <int>(); heap.Insert(0); heap.ExtractMinimum(); Assert.That(heap.IsEmpty, Is.True); Assert.That(() => heap.Minimum, Throws.InvalidOperationException); }
public void ExtractMinimum_ManyElements_CanSortSequence(params int[] values) { var heap = new PairingHeap <int>(); foreach (var value in values) { heap.Insert(value); } var sorted = new List <int>(); while (!heap.IsEmpty) { sorted.Add(heap.ExtractMinimum()); } Assert.That(sorted, Is.EqualTo(values.OrderBy(x => x).ToList())); }
public void ExtractMinimum_Empty_Throws() { var heap = new PairingHeap <int>(); Assert.That(() => heap.ExtractMinimum(), Throws.InvalidOperationException); }