Esempio n. 1
0
        public void PUT_RemoveAtContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int index)
        {
            AssumePrecondition.IsTrue(index < bh.Count && index >= 0);

            int Old_bhCount        = bh.Count;
            int Old_bhCapacity     = bh.Capacity;
            int Old_bhMinimumKey   = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("old_bhMinimumKey");
            int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("old_bhMinimumValue");
            int Old_index          = index;
            int Old_Ret_Key        = PexChoose.Value <int>("old_Ret_Key");
            int Old_Ret_Value      = PexChoose.Value <int>("old_Ret_Value");

            //code
            var ra            = bh.RemoveAt(index);
            int New_Ret_Key   = ra.Key;
            int New_Ret_Value = ra.Value;

            int New_bhCount        = bh.Count;
            int New_bhCapacity     = bh.Capacity;
            int New_bhMinimumKey   = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("new_bhMinimumKey");
            int New_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("new_bhMinimumValue");
            int New_index          = index;

            PexObserve.ValueForViewing("$old_bh_count", Old_bhCount);
            PexObserve.ValueForViewing("$new_bh_count", New_bhCount);
            PexObserve.ValueForViewing("$old_bh_capacity", Old_bhCapacity);
            PexObserve.ValueForViewing("$new_bh_capacity", New_bhCapacity);
            PexObserve.ValueForViewing("$old_bh_minimum_key", Old_bhMinimumKey);
            PexObserve.ValueForViewing("$new_bh_minimum_key", New_bhMinimumKey);
            PexObserve.ValueForViewing("$old_bh_minimum_value", Old_bhMinimumValue);
            PexObserve.ValueForViewing("$new_bh_minimum_value", New_bhMinimumValue);
            PexObserve.ValueForViewing("$old_bh_index", Old_index);
            PexObserve.ValueForViewing("$new_bh_index", New_index);
            PexObserve.ValueForViewing("$old_ret_key", Old_Ret_Key);
            PexObserve.ValueForViewing("$new_ret_key", New_Ret_Key);
            PexObserve.ValueForViewing("$old_ret_value", Old_Ret_Value);
            PexObserve.ValueForViewing("$new_ret_value", New_Ret_Value);

            PexAssert.IsTrue(false);
        }
Esempio n. 2
0
        public void PUT_RemoveAtContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int index)
        {
            AssumePrecondition.IsTrue(index < bh.Count && index >= 0);

            int Old_bhCount        = bh.Count;
            int Old_bhMinimumKey   = bh.Minimum().Key;
            int Old_bhMinimumValue = bh.Minimum().Value;
            int Old_index          = index;
            //bool Old_removeAtRoot = index == 0;

            //code
            var ra            = bh.RemoveAt(index);
            int New_Ret_Key   = ra.Key;
            int New_Ret_Value = ra.Value;


            int New_bhCount      = bh.Count;
            int New_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key: PexChoose.Value <int>("new_min_key");
            //int New_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : Old_bhMinimumKey-1;

            int New_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("new_min_val");

            //int New_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : Old_bhMinimumValue - 1;

            PexObserve.ValueForViewing("$old_bh_count", Old_bhCount);
            PexObserve.ValueForViewing("$new_bh_count", New_bhCount);
            PexObserve.ValueForViewing("$old_bh_minimum_key", Old_bhMinimumKey);
            PexObserve.ValueForViewing("$new_bh_minimum_key", New_bhMinimumKey);
            PexObserve.ValueForViewing("$old_bh_minimum_value", Old_bhMinimumValue);
            PexObserve.ValueForViewing("$new_bh_minimum_value", New_bhMinimumValue);
            PexObserve.ValueForViewing("$old_bh_index", Old_index);

            PexObserve.ValueForViewing("$new_ret_key", New_Ret_Key);
            PexObserve.ValueForViewing("$new_ret_value", New_Ret_Value);

            Assert.True(((Old_index <= New_bhCount && New_bhCount == -1 + Old_bhCount && Old_bhMinimumKey <= New_Ret_Key && Old_index >= 0)));
        }