Esempio n. 1
0
        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);
        }