Beispiel #1
0
        public void PUT_RemoveContract([PexAssumeUnderTest] HashSet.HashSet <int> hs, int x)
        {
            AssumePrecondition.IsTrue(true);

            int  Old_hsCount     = hs.Count;
            int  Old_x           = x;
            bool Old_hsContainsX = hs.Contains(x);

            bool New_Ret = hs.Remove(x);

            int  New_hsCount     = hs.Count;
            int  New_x           = x;
            bool New_hsContainsX = hs.Contains(x);

            PexObserve.ValueForViewing("$old_hs_Count", Old_hsCount);
            PexObserve.ValueForViewing("$new_hs_Count", New_hsCount);
            PexObserve.ValueForViewing("$old_hs_x", Old_x);
            PexObserve.ValueForViewing("$new_hs_x", New_x);
            PexObserve.ValueForViewing("$New_ret", New_Ret);
            PexObserve.ValueForViewing("$old_hs_contains_x", Old_hsContainsX);
            PexObserve.ValueForViewing("$new_hs_contains_x", New_hsContainsX);


            Assert.True(((New_x == Old_x && (!(New_hsContainsX))) && ((((New_Ret && New_hsCount == Old_hsCount - 1 && New_hsCount != Old_hsCount) && (((New_hsCount == Old_x && Old_x != Old_hsCount && New_x != Old_hsCount && Old_x == New_hsCount) && New_x == New_hsCount) || ((Old_x != New_hsCount && New_x != New_hsCount) && (!(New_x == New_hsCount))))) && Old_hsContainsX) || (((New_hsCount == Old_hsCount && (!(New_Ret))) && (((New_x == Old_hsCount && Old_x == Old_hsCount && Old_x == New_hsCount) && New_x == New_hsCount) || ((Old_x != Old_hsCount && New_x != Old_hsCount && Old_x != New_hsCount && New_x != New_hsCount) && (!(New_x == New_hsCount))))) && (!(Old_hsContainsX))))));
        }
Beispiel #2
0
        public static MySet.HashSet <string> GetTable(string[] words)
        {
            var table = new HashSet.HashSet <string>();

            foreach (var word in words)
            {
                table.Add(word);
            }
            return(table);
        }
Beispiel #3
0
        public static MySet.HashSet<string> GetTable(string[] words)
        {
            var table = new HashSet.HashSet<string>();
            foreach (var word in words)
            {
                    table.Add(word);

            }
            return table;
        }
Beispiel #4
0
        public void PUT_CountContract([PexAssumeUnderTest] HashSet.HashSet <int> hs)
        {
            AssumePrecondition.IsTrue(true);

            int Old_hsCount = hs.Count;


            int New_Ret = hs.Count;

            int New_hsCount = hs.Count;

            PexObserve.ValueForViewing("$old_hs_Count", Old_hsCount);
            PexObserve.ValueForViewing("$new_hs_Count", New_hsCount);
            PexObserve.ValueForViewing("$New_ret", New_Ret);

            Assert.True((New_hsCount == Old_hsCount && New_Ret == Old_hsCount && New_Ret == New_hsCount));
        }
Beispiel #5
0
        public static HashSet.HashSet <int> Create([PexAssumeNotNull] int[] elems)
        {
            //PexAssume.IsTrue(elems != null && elems.Length < 11);
            //PexAssume.TrueForAll(0, elems.Length, _i => elems[_i] > -11 && elems[_i] < 11);
            PexAssume.AreDistinctValues(elems);
            HashSet.HashSet <int> ret = new HashSet.HashSet <int>();// DataStructure has big enough capacity for Commutativity Test
            for (int i = 0; i < elems.Length; i++)
            {
                //PexAssume.IsTrue(elems[i] > -101 && elems[i] < 101);

                // For stack, add any element.
                //if(!ret.Contains(elems[i]))
                ret.Add(elems[i]);
            }

            return(ret);
        }
        public static HashSet.HashSet <int> CreateChoose(int min, int max)
        {
            //PexAssume.IsTrue(elems != null && elems.Length < 11);

            //PexAssume.AreDistinctValues(elems);
            //PexChoose.
            PexAssume.IsTrue(min <= 0 || min > 0);
            PexAssume.IsTrue(max <= 0 || max > 0);
            HashSet.HashSet <int> ret = new HashSet.HashSet <int>();// DataStructure has big enough capacity for Commutativity Test
            //for (int i = 0; i < elems.Length; i++)
            //{
            //PexAssume.IsTrue(elems[i] > -101 && elems[i] < 101);

            // For stack, add any element.
            //if(!ret.Contains(elems[i]))
            ret.Add(PexChoose.ValueFromRange("elements", min, max));
            //}

            return(ret);
        }
        public void PUT_CountContract([PexAssumeUnderTest] HashSet.HashSet <int> hs)
        {
            AssumePrecondition.IsTrue(true);

            //int Old_hsCount = hs.Count;


            int New_Ret = hs.Count;

            //code
            //int New_hsCount = hs.Count;
            //bool New_ContainsNewRet = hs.Contains(New_Ret);

            //PexObserve.ValueForViewing("$old_hs_Count", Old_hsCount);
            //PexObserve.ValueForViewing("$new_hs_Count", New_hsCount);
            PexObserve.ValueForViewing("$New_ret", New_Ret);
            //PexObserve.ValueForViewing("$new_containsNewRet", New_ContainsNewRet);

            Assert.True((New_Ret >= 1 || New_Ret == 0));
        }
        public void PUT_ContainsContract([PexAssumeUnderTest] HashSet.HashSet <int> hs, int x)
        {
            AssumePrecondition.IsTrue(true);

            int Old_hsCount = hs.Count;
            int Old_x       = x;
            //bool Old_hsContainsX = hs.Contains(x);
            //code
            bool New_Ret = hs.Contains(x);

            int New_hsCount = hs.Count;

            //bool New_hsContainsX = hs.Contains(x);

            PexObserve.ValueForViewing("$old_hs_Count", Old_hsCount);
            PexObserve.ValueForViewing("$new_hs_Count", New_hsCount);
            PexObserve.ValueForViewing("$old_x", Old_x);
            PexObserve.ValueForViewing("$New_ret", New_Ret);
            //PexObserve.ValueForViewing("$old_hs_contains_x", Old_hsContainsX);
            //PexObserve.ValueForViewing("$new_hs_contains_x", New_hsContainsX);

            Assert.True(((New_hsCount == Old_hsCount && (!(New_Ret)) && Old_hsCount >= 0) || (New_hsCount == Old_hsCount && Old_hsCount >= 1)));
        }