Example #1
0
        private void CompareList(List <int> _list, ZStackByList <int> stack)
        {
            Assert.AreEqual(_list.Count, stack.Count);
            List <int> stackList = stack.ToList();

            stackList.Reverse();
            CollectionAssert.AreEqual(_list, stackList);
        }
Example #2
0
        private ZStackByList <int> InitializeZStackByList()
        {
            ZStackByList <int> stack = new ZStackByList <int>();

            for (int i = 0; i < list.Count; i++)
            {
                stack.Push(list[i]);
            }

            return(stack);
        }
Example #3
0
        public void ZStackByListTestReverse()
        {
            ZStackByList <int> stack = InitializeZStackByList();
            List <int>         _list = new List <int>()
            {
                6, 5, 4, 3, 2, 1, 7, 8, 9, 10
            };

            _list.Reverse();
            stack.Reverse();
            CompareList(_list, stack);
        }
Example #4
0
        public void ZStackByListTestSort()
        {
            ZStackByList <int> stack = InitializeZStackByList();
            List <int>         _list = new List <int>()
            {
                6, 5, 4, 3, 2, 1, 7, 8, 9, 10
            };

            _list.Sort();
            stack.Sort();
            Assert.AreEqual(_list.Count, stack.Count);
            CollectionAssert.AreEqual(_list, stack.ToList());
        }
Example #5
0
        public void ZStackByListTestPop()
        {
            ZStackByList <int> stack = InitializeZStackByList();

            Assert.AreEqual(10, stack.Pop());
            Assert.AreEqual(9, stack.Pop());
            Assert.AreEqual(8, stack.Pop());
            Assert.AreEqual(7, stack.Pop());
            Assert.AreEqual(1, stack.Pop());
            Assert.AreEqual(2, stack.Pop());
            Assert.AreEqual(3, stack.Pop());
            Assert.AreEqual(4, stack.Pop());
            Assert.AreEqual(5, stack.Pop());
            Assert.AreEqual(6, stack.Pop());
            Assert.AreEqual(0, stack.Count);
        }
Example #6
0
        public void ZStackByListTestPush()
        {
            ZStackByList <int> stack = InitializeZStackByList();

            CompareList(list, stack);
        }