Ejemplo n.º 1
0
        private void CompareList(List <int> _list, ZStackByLinkedList <int> stack)
        {
            Assert.AreEqual(_list.Count, stack.Count);
            List <int> stackList = stack.ToList();

            stackList.Reverse();
            CollectionAssert.AreEqual(_list, stackList);
        }
Ejemplo n.º 2
0
        private ZStackByLinkedList <int> InitializeZStackByLinkedList()
        {
            ZStackByLinkedList <int> stack = new ZStackByLinkedList <int>();

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

            return(stack);
        }
Ejemplo n.º 3
0
        public void ZStackByLinkedListTestReverse()
        {
            ZStackByLinkedList <int> stack = InitializeZStackByLinkedList();
            List <int> _list = new List <int>()
            {
                6, 5, 4, 3, 2, 1, 7, 8, 9, 10
            };

            _list.Reverse();
            stack.Reverse();
            CompareList(_list, stack);
        }
Ejemplo n.º 4
0
        public void ZStackByLinkedListTestSort()
        {
            ZStackByLinkedList <int> stack = InitializeZStackByLinkedList();
            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());
        }
Ejemplo n.º 5
0
        public void ZStackByLinkedListTestPop()
        {
            ZStackByLinkedList <int> stack = InitializeZStackByLinkedList();

            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);
        }
Ejemplo n.º 6
0
        public void ZStackByLinkedListTestPush()
        {
            ZStackByLinkedList <int> stack = InitializeZStackByLinkedList();

            CompareList(list, stack);
        }