예제 #1
0
        public void CreateStack_Test()
        {
            StackStaticLength obj = new StackStaticLength();

            obj.Push(5);
            obj.Push(6);

            Assert.Equal(6, obj.PeekTop());
        }
예제 #2
0
        public void IsStackFull_Test()
        {
            var obj = new StackStaticLength();

            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            Assert.Throws <System.IndexOutOfRangeException>(() => obj.Push(1));
        }
예제 #3
0
        public void EmptyStack_Test()
        {
            var obj = new StackStaticLength();

            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.Push(1);
            obj.EmptyStack();
            Assert.Equal(0, obj.StackLength());
            obj.Push(1);
            Assert.Equal(1, obj.StackLength());
        }