Пример #1
0
        public void ExercisePushPopPeak()
        {
            var s = new StackViaLinkedList <int>();

            s.Push(5);
            Assert.AreEqual(5, s.Peak());
            s.Push(45);
            s.Push(-34);
            Assert.AreEqual(-34, s.Peak());
            Assert.AreEqual(-34, s.Pop());
            Assert.AreEqual(45, s.Peak());
            Assert.AreEqual(45, s.Pop());
            Assert.AreEqual(5, s.Peak());
        }
Пример #2
0
        public void ExceptionThrownOnPeakOnEmptyStack()
        {
            var s = new StackViaLinkedList <int>();

            Assert.Throws <IndexOutOfRangeException>(() => s.Peak());
        }