public void InsertAndMinimum <TPriority, TValue>( [PexAssumeUnderTest] BinaryHeap <TPriority, TValue> target, [PexAssumeNotNull] KeyValuePair <TPriority, TValue>[] kvs) { PexAssume.IsTrue(kvs.Length > 0); var count = target.Count; TPriority minimum = default(TPriority); for (int i = 0; i < kvs.Length; ++i) { var kv = kvs[i]; if (i == 0) { minimum = kv.Key; } else { minimum = target.PriorityComparison(kv.Key, minimum) < 0 ? kv.Key : minimum; } target.Add(kv.Key, kv.Value); // check minimum var kvMin = target.Minimum(); Assert.AreEqual(minimum, kvMin.Key); } AssertInvariant <TPriority, TValue>(target); }
public void InsertAndRemoveMinimum <TPriority, TValue>( [PexAssumeUnderTest] BinaryHeap <TPriority, TValue> target, [PexAssumeNotNull] KeyValuePair <TPriority, TValue>[] kvs) { var count = target.Count; foreach (var kv in kvs) { target.Add(kv.Key, kv.Value); } TPriority minimum = default(TPriority); for (int i = 0; i < kvs.Length; ++i) { if (i == 0) { minimum = target.RemoveMinimum().Key; } else { var m = target.RemoveMinimum().Key; Assert.IsTrue(target.PriorityComparison(minimum, m) <= 0); minimum = m; } AssertInvariant(target); } Assert.AreEqual(0, target.Count); }