Exemplo n.º 1
0
        public void ToArray()
        {
            var stack       = new Stack <string>(Globals.Strings);
            var systemStack = new S.Stack <string>(Globals.Strings);

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

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

            var stackArray       = stack.ToArray();
            var systemStackArray = systemStack.ToArray();

            Comparer <string> .Compare(stackArray, systemStackArray);

            Assert.IsTrue(stackArray.Length == systemStackArray.Length);


            var queue       = new Queue <string>(Globals.Strings);
            var systemQueue = new S.Queue <string>(Globals.Strings);

            Comparer <string> .Compare(queue, systemQueue);

            Comparer <string> .Compare(queue, systemQueue);

            var queueArray       = queue.ToArray();
            var systemQueueArray = systemQueue.ToArray();

            Comparer <string> .Compare(queueArray, systemQueueArray);

            Assert.IsTrue(queueArray.Length == systemQueueArray.Length);
        }
Exemplo n.º 2
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) { }
        }
Exemplo n.º 3
0
        public void Contains()
        {
            var stack  = new Stack <char>(Globals.Chars);
            var system = new S.Stack <char>(Globals.Chars);

            for (char c = '\0'; c < char.MaxValue; c++)
            {
                if (stack.Contains(c) != Globals.Chars.Contains(c) || stack.Contains(c) != system.Contains(c))
                {
                    Assert.Fail();
                }
            }
        }
Exemplo n.º 4
0
        public void Clear()
        {
            var stack  = new Stack <int>(Globals.Ints);
            var system = new S.Stack <int>(Globals.Ints);

            Assert.IsTrue(stack.Count == Globals.Ints.Length);
            Comparer <int> .Compare(stack, system);

            stack.Clear();
            system.Clear();

            Assert.IsTrue(stack.Count == 0);
            Comparer <int> .Compare(stack, system);
        }
Exemplo n.º 5
0
        public void Contains()
        {
            var stack  = new Stack <string>(Globals.Strings);
            var system = new S.Stack <string>(Globals.Strings);

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

            foreach (var s in Globals.Strings)
            {
                Assert.IsTrue(stack.Contains(s));
            }

            Comparer <string> .Compare(stack, system);
        }
Exemplo n.º 6
0
        public void Constructor()
        {
            var stack  = new Stack <string>();
            var system = new S.Stack <string>();

            Assert.IsTrue(stack.Count == 0);
            Comparer <string> .Compare(stack, system);

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

            Assert.IsTrue(stack.Count == system.Count && stack.Count == Globals.Strings.Length);
            Comparer <string> .Compare(stack, system);
        }
Exemplo n.º 7
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 _));
        }
Exemplo n.º 8
0
        public void Push()
        {
            var stack  = new Stack <int>();
            var system = new S.Stack <int>();

            foreach (var item in Globals.Ints)
            {
                stack.Push(item);
                system.Push(item);

                Comparer <int> .Compare(stack, system);
            }

            Comparer <int> .Compare(stack, system);
        }
Exemplo n.º 9
0
        public void Push()
        {
            var stack  = new Stack <string>();
            var system = new S.Stack <string>();

            foreach (var item in Globals.Strings)
            {
                stack.Push(item);
                system.Push(item);

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

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