예제 #1
0
        private void PopAndMinTest(IMinStack minStack)
        {
            int min = minStack.Min();

            Assert.AreEqual(1, min);
            int pop = minStack.Pop();

            Assert.AreEqual(1, pop);

            min = minStack.Min();
            Assert.AreEqual(3, min);
            pop = minStack.Pop();
            Assert.AreEqual(6, pop);

            min = minStack.Min();
            Assert.AreEqual(3, min);
            pop = minStack.Pop();
            Assert.AreEqual(3, pop);

            try
            {
                pop = minStack.Pop();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Stack empty.", ex.Message);
            }
        }
예제 #2
0
 private void PushTest(IMinStack minStack)
 {
     int[] data = new int[] { 3, 6, 1 };
     for (int i = 0; i < data.Length; i++)
     {
         int value = data[i];
         minStack.Push(value);
         Assert.AreEqual(value, minStack.Peek());
     }
 }
예제 #3
0
 private void RunTests(IMinStack minStack)
 {
     PushTest(minStack);
     PopAndMinTest(minStack);
 }