Esempio 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);
        }
Esempio n. 2
0
        public void Dequeue()
        {
            var queue = new Queue <string>();

            try
            {
                queue.Dequeue();
                Assert.Fail();
            }
            catch (InvalidOperationException) { }

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

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

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

            try
            {
                queue.Dequeue();
                Assert.Fail();
            }
            catch (InvalidOperationException) { }
        }
Esempio n. 3
0
        public void Contains()
        {
            var queue  = new Queue <char>(Globals.Chars);
            var system = new S.Queue <char>(Globals.Chars);

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

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

            queue.Clear();
            system.Clear();

            Assert.IsTrue(queue.Count == 0);
            Comparer <int> .Compare(queue, system);
        }
Esempio n. 5
0
        public void TryDequeue()
        {
            var queue  = new Queue <string>(Globals.Strings);
            var system = new S.Queue <string>(Globals.Strings);

            while (queue.TryDequeue(out string first))
            {
                Assert.IsTrue(first == system.Dequeue());
                Comparer <string> .Compare(queue, system);
            }

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

            Assert.IsFalse(queue.TryDequeue(out _));
        }
Esempio n. 6
0
        public void Enqueue()
        {
            var queue  = new Queue <int>();
            var system = new S.Queue <int>();

            foreach (var item in Globals.Ints)
            {
                queue.Enqueue(item);
                system.Enqueue(item);

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

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