Пример #1
0
        public void Pop()
        {
            var stack = new Stack <string>();

            try
            {
                stack.Pop();
                Assert.Fail();
            }
            catch (InvalidOperationException) { }

            stack = new Stack <string>(Globals.Strings);
            var system = new S.Stack <string>(Globals.Strings);

            while (stack.Count != 0)
            {
                Assert.IsTrue(stack.Pop() == system.Pop());
                Comparer <string> .Compare(stack, system);
            }

            Assert.IsTrue(stack.Count == system.Count && stack.Count == 0);

            try
            {
                stack.Pop();
                Assert.Fail();
            }
            catch (InvalidOperationException) { }
        }
Пример #2
0
        public void TryPop()
        {
            var stack  = new Stack <string>(Globals.Strings);
            var system = new S.Stack <string>(Globals.Strings);

            while (stack.TryPop(out string first))
            {
                Assert.IsTrue(first == system.Pop());
                Comparer <string> .Compare(stack, system);
            }

            Comparer <string> .Compare(stack, system);

            Assert.IsFalse(stack.TryPop(out _));
        }