예제 #1
0
        public void PopTestSuccess()
        {
            var s = new CStack(10);
            s.Push(11);

            Assert.AreEqual(1, s.Size);

            int popRtrn = s.Pop();
            Assert.AreEqual(11, popRtrn);
            Assert.AreEqual(0, s.Size);
        }
예제 #2
0
        public void MultiplePushTestErrorIndexOutOfRangeException()
        {
            var x = new CStack(4);

            x.Push(10);
            Assert.AreEqual(10, x.Top());
            Assert.AreEqual(1, x.Size);

            x.Push(20);
            Assert.AreEqual(20, x.Top());
            Assert.AreEqual(2, x.Size);

            x.Push(30);
            Assert.AreEqual(30, x.Top());
            Assert.AreEqual(3, x.Size);

            x.Push(40);
            Assert.AreEqual(40, x.Top());
            Assert.AreEqual(4, x.Size);

            x.Push(50);
        }
예제 #3
0
        public void MultiplePushTestSuccess()
        {
            var x = new CStack(5);

            x.Push(10);
            Assert.AreEqual(10, x.Top());
            Assert.AreEqual(1, x.Size);

            x.Push(20);
            Assert.AreEqual(20, x.Top());
            Assert.AreEqual(2, x.Size);

            x.Push(30);
            Assert.AreEqual(30, x.Top());
            Assert.AreEqual(3, x.Size);

            x.Push(40);
            Assert.AreEqual(40, x.Top());
            Assert.AreEqual(4, x.Size);

            x.Push(-50);
            Assert.AreEqual(-50, x.Top());
            Assert.AreEqual(5, x.Size);
        }
예제 #4
0
 public void PushTestSuccess()
 {
     var s = new CStack(10);
     s.Push(10);
     Assert.AreEqual(1, s.Size);
 }
예제 #5
0
 public void PushTestErrorIndexOutOfRangeException()
 {
     var s = new CStack(0);
     s.Push(10);
 }
예제 #6
0
        public void TopTestSuccess()
        {
            var s = new CStack(10);
            s.Push(19);

            Assert.AreEqual(19, s.Top());
            Assert.AreEqual(1, s.Size);
        }