Exemplo n.º 1
0
        public void PUT_DequeueContract([PexAssumeUnderTest] Queue.Queue <int> s1)
        {
            AssumePrecondition.IsTrue(s1.Count > 0);
            int Old_s1Count = s1.Count;
            //int Old_Ret = PexChoose.Value<int>("old_ret");
            int Old_Top = s1.Peek();

            /*code*/
            int New_Ret = s1.Dequeue();

            //Old_ret = New_ret;
            int New_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("old_ret");
            //int New_Top = s1.Count > 0 ? s1.Peek() : Old_Top - 2;
            int  New_s1Count          = s1.Count;
            bool New_s1ContainsNewRet = s1.Contains(New_Ret);

            PexObserve.ValueForViewing("$Old_s1_Count", Old_s1Count);
            PexObserve.ValueForViewing("$New_s1_Count", New_s1Count);
            PexObserve.ValueForViewing("$Old_s1_Peek", Old_Top);
            PexObserve.ValueForViewing("$new_s1_Peek", New_Top);
            //PexObserve.ValueForViewing("$Old_ret", Old_Ret);
            PexObserve.ValueForViewing("$New_ret", New_Ret);
            PexObserve.ValueForViewing("$New_s1ContainsNewRet", New_s1ContainsNewRet);

            Assert.True(((New_s1Count == -1 + Old_s1Count && New_Ret == Old_Top && (!(New_Ret == Old_s1Count)))));
        }
Exemplo n.º 2
0
        public void DeTest()
        {
            var q = new Queue.Queue <int>();

            q.Enqueue(6);
            q.Enqueue(7);
            q.Dequeue();
            Assert.Equal(7, q.Peek());
        }
Exemplo n.º 3
0
 public void Test_Queue_string()
 {
     Queue.Queue <string> myQ = new Queue.Queue <string>();
     myQ.Enqueue("appels");
     myQ.Enqueue("peren");
     myQ.Enqueue("sinaasappels");
     myQ.Enqueue("kiwi's");
     Assert.AreEqual(myQ.First, "appels");
     myQ.Dequeue();
     Assert.AreEqual(myQ.First, "peren");
 }
Exemplo n.º 4
0
        public void Test_Queue_int()
        {
            Queue.Queue <int> myQ = new Queue.Queue <int>();
            myQ.Enqueue(1); myQ.Enqueue(2);
            myQ.Enqueue(3);
            myQ.Enqueue(4);
            Assert.AreEqual(myQ.Length, 4);
            myQ.Dequeue();
            Assert.AreEqual(myQ.Length, 3);
            Assert.AreEqual(myQ.IsEmpty, false);
            var TestList = new List <string>()
            {
                "2", "3", "4"
            };
            int i = 0;

            foreach (int elem in myQ)
            {
                Assert.AreEqual(elem.ToString(), TestList[i]);
                i++;
            }
        }