コード例 #1
0
        public void PUT_IndexOfContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int value)
        {
            AssumePrecondition.IsTrue(true);

            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_value          = value;

            //code
            int New_Ret = bh.IndexOf(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_value          = value;

            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_value", Old_value);
            PexObserve.ValueForViewing("$new_bh_value", New_value);
            PexObserve.ValueForViewing("$new_ret", New_Ret);

            Assert.IsTrue(false);
        }
コード例 #2
0
        public void PUT_IndexOfContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int value)
        {
            // ahmad you can do this one: alternate semantics is that old ket and new key are the same; The same holds true for value
            AssumePrecondition.IsTrue(true);

            int Old_bhCount        = bh.Count;
            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_value          = value;

            //code
            int New_Ret = bh.IndexOf(value);

            int New_bhCount        = bh.Count;
            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");

            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_value", Old_value);
            PexObserve.ValueForViewing("$new_ret", New_Ret);


            Assert.True((((!(New_Ret == Old_bhCount)) && New_Ret <= Old_bhCount && Old_bhCount <= New_bhCount && New_bhCount <= Old_bhCount && New_Ret >= -1)));
        }
コード例 #3
0
        public void PUT_UpdateContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int priority, int value)
        {
            //ahmad alternate semantics
            AssumePrecondition.IsTrue(true);

            int Old_bhCount        = bh.Count;
            int Old_bhIndexOfValue = bh.IndexOf(value);
            int Old_bhMinimumKey   = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("old_bhMinimumKey");
            //int Old_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : priority -1;

            int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("old_bhMinimumValue");
            //int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : value -1;

            //int Old_bhMinimumKey = bh.Minimum().Key ;
            //int Old_bhMinimumValue = bh.Minimum().Value;
            int Old_priority = priority;
            int Old_value    = value;

            //code
            bh.Update(priority, value);

            int New_bhCount        = bh.Count;
            int New_bhIndexOfValue = bh.IndexOf(value);
            //int New_bhMinimumKey = bh.Minimum().Key;
            int New_bhMinimumKey = bh.Minimum().Key;
            //int New_bhMinimumValue =  bh.Minimum().Value;
            int New_bhMinimumValue = bh.Minimum().Value;

            //int New_prioirty = priority;
            //int New_value = value;

            PexObserve.ValueForViewing("$old_bh_count", Old_bhCount);
            PexObserve.ValueForViewing("$new_bh_count", New_bhCount);
            PexObserve.ValueForViewing("$old_bh_indexof_value", Old_bhIndexOfValue);
            PexObserve.ValueForViewing("$new_bh_indexof_value", New_bhIndexOfValue);
            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_priority", Old_priority);
            //PexObserve.ValueForViewing("$new_bh_priority", New_prioirty);
            PexObserve.ValueForViewing("$old_bh_value", Old_value);
            //PexObserve.ValueForViewing("$new_bh_value", New_value);

            Assert.True(((Old_bhCount <= New_bhCount && New_bhMinimumKey <= Old_priority && (!(New_bhIndexOfValue == New_bhCount)) && (!(Old_bhIndexOfValue == Old_bhCount)) && Old_bhIndexOfValue <= Old_bhCount && New_bhIndexOfValue <= Old_bhCount && New_bhIndexOfValue >= 0 && Old_bhIndexOfValue >= -1)));
        }
コード例 #4
0
        public void PUT_UpdateContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int priority, int value)
        {
            AssumePrecondition.IsTrue(bh.IndexOf(value) >= 0);

            int Old_bhCount        = bh.Count;
            int Old_bhCapacity     = bh.Capacity;
            int Old_bhIndexOfValue = bh.IndexOf(value);
            //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_bhMinimumKey   = bh.Minimum().Key;
            int Old_bhMinimumValue = bh.Minimum().Value;
            int Old_prioirty       = priority;
            int Old_value          = value;

            //code
            bh.Update(priority, value);

            int New_bhCount         = bh.Count;
            int New_bhCapacity      = bh.Capacity;
            int Newd_bhIndexOfValue = bh.IndexOf(value);
            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_prioirty        = priority;
            int New_value           = value;

            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_indexof_value", Old_bhIndexOfValue);
            PexObserve.ValueForViewing("$new_bh_indexof_value", Newd_bhIndexOfValue);
            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_priority", Old_prioirty);
            PexObserve.ValueForViewing("$new_bh_priority", New_prioirty);
            PexObserve.ValueForViewing("$old_bh_value", Old_value);
            PexObserve.ValueForViewing("$new_bh_value", New_value);


            Assert.IsTrue(false);
        }
コード例 #5
0
        public void PUT_AddContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int key, int value)
        {
            AssumePrecondition.IsTrue(true);

            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_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : key + 1; //PexChoose.Value<int>("old_bhMinimumKey");
            //int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : value + 1; //PexChoose.Value<int>("old_bhMinimumValue");

            int Old_bhIndexOfValue = bh.IndexOf(value);
            int Old_key            = key;
            int Old_value          = value;

            //code
            bh.Add(key, value);

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

            PexObserve.ValueForViewing("$old_bh_count", Old_bhCount);
            PexObserve.ValueForViewing("$new_bh_count", New_bhCount);
            PexObserve.ValueForViewing("$old_bh_key", Old_key);
            PexObserve.ValueForViewing("$old_bh_value", Old_value);
            //PexObserve.ValueForViewing("$old_bh_capacity", Old_bhCapacity);
            //PexObserve.ValueForViewing("$new_bh_capacity", New_bhCapacity);
            PexObserve.ValueForViewing("$old_bh_indexof_value", Old_bhIndexOfValue);
            PexObserve.ValueForViewing("$new_bh_indexof_value", New_bhIndexOfValue);
            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);

            Assert.True(((New_bhMinimumKey <= Old_key && New_bhCount == 1 + Old_bhCount && (!(Old_bhIndexOfValue == Old_bhCount)) && Old_bhIndexOfValue <= Old_bhCount && New_bhIndexOfValue <= Old_bhCount && New_bhIndexOfValue >= 0 && Old_bhIndexOfValue >= -1)));
        }