public void Peek_1Node_CorrectValue() { var fh = new FibonacciHeap <int>(); fh.Push(3); Assert.AreEqual(3, fh.Peek()); }
public void Peek_2NodesSmallerLast_CorrectValue() { var fh = new FibonacciHeap <int>(); fh.Push(3); fh.Push(2); Assert.AreEqual(2, fh.Peek()); }
public void Peek_MultipleValues_CorrectValue(int[] sequence) { var fh = new FibonacciHeap <int>(); foreach (var value in sequence) { if (value < 0) { var val = fh.Peek(); Assert.AreEqual(System.Math.Abs(value), val); } else { fh.Push(value); } } }
public static void Union_EmptyHeap_BecomesOtherHeap() { var thisHeap = new FibonacciHeap <int>(); var otherHeap = BuildTestHeap(); var minNode = otherHeap.Peek(); var otherCount = otherHeap.Count; Assert.Zero(thisHeap.Count); thisHeap.Union(otherHeap); Assert.Zero(otherHeap.Count); Assert.AreEqual(thisHeap.Peek(), minNode); Assert.Throws <InvalidOperationException>(() => otherHeap.Peek()); Assert.AreEqual(otherCount, thisHeap.Count); }
public static void Peek_EmptyHeap_ThrowsCorrectException() { var heap = new FibonacciHeap <int>(); Assert.Throws <InvalidOperationException>(() => heap.Peek()); }