示例#1
0
        public static void stackMinTest(StackWithMin m)
        {
            for (int i = 0; i < 4; i++)
            {
                m.pop();
                Assert.True(m.min().Equals(1));
            }

            m.pop();
            Assert.True(m.min().Equals(2));
        }
示例#2
0
        public static void stackMinExceptionTest()
        {
            StackWithMin min       = new StackWithMin();
            var          exception = Record.Exception(() => min.pop());

            Assert.NotNull(exception);
            Assert.IsType <EmptyStackException>(exception);
        }
示例#3
0
        static void Main(string[] args)
        {
            StackWithMin stack = new StackWithMin();
            stack.push(5);
            stack.push(6);
            stack.push(3);
            stack.push(7);
            Console.WriteLine(stack.Min());
            stack.pop();
            stack.pop();
            Console.WriteLine(stack.Min());

            StackWithMin2 stack2 = new StackWithMin2();
            stack2.push(5);
            stack2.push(6);
            stack2.push(3);
            stack2.push(7);
            Console.WriteLine(stack2.Min());
            stack2.pop();
            stack2.pop();
            Console.WriteLine(stack2.Min());
        }