Exemplo n.º 1
0
        public void CountZeroReversedTest()
        {
            var array       = new Deque <int>();
            var reverseView = DequeTest.GetReverseView(array);

            Assert.AreEqual(0, reverseView.Count);
        }
Exemplo n.º 2
0
        public void ReverseIndexOf()
        {
            var d = new Deque <int> {
                1, 2, 3, 4, 5, 6
            };
            var reverseView = DequeTest.GetReverseView(d);

            Assert.AreEqual(d.Count - 1, reverseView.IndexOf(1));
            Assert.AreEqual(3, reverseView.IndexOf(3));
        }
Exemplo n.º 3
0
        public void ContainsReversedTest()
        {
            var array       = new Deque <int>();
            var reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < 20; i++)
            {
                array.Add(i);
            }
            Assert.AreEqual(true, reverseView.Contains(10));
        }
Exemplo n.º 4
0
        public void IndexOfReverseTest()
        {
            var array       = new Deque <int>();
            var reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < 20; i++)
            {
                array.Add(i);
            }
            Assert.AreEqual(9, reverseView.IndexOf(10));
        }
Exemplo n.º 5
0
        public void LastReversedTest()
        {
            const int repetition  = 10000;
            var       array       = new Deque <int>();
            var       reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < repetition; i++)
            {
                array.Add(i + 1);
            }
            Assert.AreEqual(1, reverseView.Last);
        }
Exemplo n.º 6
0
        public void AddNullTest()
        {
            var array       = new Deque <string>();
            var reverseView = DequeTest.GetReverseView(array);

            array.Add("tacocat");
            array.Add(null);
            array.Add("tacocat"); // writen reversed :D
            array.Add(null);
            Assert.AreEqual(1, array.IndexOf(null));
            Assert.AreEqual(0, reverseView.IndexOf(null));
        }
Exemplo n.º 7
0
        public void CountReverseTest()
        {
            const int repetition  = 400;
            var       array       = new Deque <int>();
            var       reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < repetition; i++)
            {
                reverseView.Add(i);
            }
            Assert.AreEqual(repetition, array.Count);
            Assert.AreEqual(repetition, reverseView.Count);
        }
Exemplo n.º 8
0
        public void SelfEqualityReversedTest()
        {
            var array = new Deque <int> {
                0, 1, 2, 3, 4, 5
            };
            var reverseView = DequeTest.GetReverseView(array);
            int i           = 0;

            foreach (var item in reverseView)
            {
                Assert.AreEqual(item, reverseView[i++]);
            }
        }
Exemplo n.º 9
0
        public void RemoveAtReverseTest()
        {
            var array       = new Deque <int>();
            var reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < 3; i++)
            {
                array.Add(i);
            }
            reverseView.RemoveAt(0);
            Assert.AreEqual(2, array.Count);
            Assert.AreEqual(0, array[0]);
            Assert.AreEqual(1, array[1]);
        }
Exemplo n.º 10
0
        public void GetEnumeratorReversedTest()
        {
            const int repetition  = 10000;
            var       array       = new Deque <int>();
            var       reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < repetition; i++)
            {
                array.Add(i);
            }
            int x = repetition - 1;

            foreach (var o in reverseView)
            {
                Assert.AreEqual(x--, o);
            }
        }
Exemplo n.º 11
0
        public void InsertReverseTest()
        {
            var array       = new Deque <int>();
            var reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < 200; i++)
            {
                reverseView.Insert(0, i);
            }
            Assert.AreEqual(200, array.Count, "count not equal");
            int x = 0;

            foreach (var o in array)
            {
                Assert.AreEqual(x++, o);
            }
        }
Exemplo n.º 12
0
        public void InsertBasicReversedTest()
        {
            var array       = new Deque <int>();
            var reverseView = DequeTest.GetReverseView(array);

            array.Insert(0, 3);
            array.Insert(0, 2);
            array.Insert(0, 1);
            reverseView.Insert(0, 4);
            reverseView.Insert(0, 5);
            reverseView.Insert(0, 6);

            for (int i = 1; i < 7; i++)
            {
                Assert.AreEqual(i, array[i - 1]);
            }
        }
Exemplo n.º 13
0
        public void AddTestLargeReverse()
        {
            const int repetition  = 10000;
            var       array       = new Deque <int>();
            var       reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < repetition; i++)
            {
                reverseView.Add(i);
            }
            Assert.AreEqual(repetition, array.Count);
            Assert.AreEqual(repetition, reverseView.Count);
            for (int i = 0; i < repetition; i++)
            {
                Assert.AreEqual(i, array[repetition - i - 1]);
            }
        }
Exemplo n.º 14
0
        public void CopyToReversedTest()
        {
            var array       = new Deque <int>();
            var reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < 100; i++)
            {
                array.Add(i);
            }
            var newarray = new int[200];

            reverseView.CopyTo(newarray, 25);

            Assert.AreEqual(0, newarray[25]);
            Assert.AreEqual(1, newarray[26]);
            Assert.AreEqual(99, newarray[124]);
        }
Exemplo n.º 15
0
        public void ClearReversedTest()
        {
            var array       = new Deque <int>();
            var reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < 20; i++)
            {
                array.Add(i);
            }
            reverseView.Clear();
            Assert.AreEqual(0, array.Count);

            for (int i = 0; i < 20; i++)
            {
                array.Add(i);
            }
            Assert.AreEqual(20, reverseView.Count);
        }
Exemplo n.º 16
0
        public void EnumChange15_GetReverse()
        {
            Deque <string> someNames = new Deque <string>();

            someNames.Add("Bill");
            someNames.Add("Mike");
            someNames.Add("Alice");
            someNames.Add("Trevor");
            someNames.Add("Scott");
            IList <string> a;

            foreach (string s in someNames)
            {
                if (s.StartsWith("A"))
                {
                    a = DequeTest.GetReverseView(someNames);
                }
            }
            someNames.Add("Help");
        }
Exemplo n.º 17
0
        public void IndexerGetReversedLargeTest()
        {
            const int repetition  = 10000;
            var       array       = new Deque <int>();
            var       reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < repetition; i++)
            {
                array.Add(i);
            }
            Assert.AreEqual(0, reverseView[repetition - 1]);
            Assert.AreEqual(repetition - 1, reverseView[0]);
            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                var temp = reverseView[-1];
            });
            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                var temp = reverseView[repetition];
            });
        }
Exemplo n.º 18
0
        public void ReverseAdd()
        {
            Deque <int> deque = new Deque <int>();

            deque.Add(1); deque.Add(2); deque.Add(3);
            IList <int> reverse = DequeTest.GetReverseView(deque);

            Assert.AreEqual(0, deque.IndexOf(1));
            Assert.AreEqual(2, reverse.IndexOf(1));
            Assert.AreEqual(1, deque[0]);
            Assert.AreEqual(2, deque[1]);
            Assert.AreEqual(3, deque[2]);
            Assert.AreEqual(3, reverse[0]);
            Assert.AreEqual(2, reverse[1]);
            Assert.AreEqual(1, reverse[2]);

            deque.Add(100);

            Assert.AreEqual(4, deque.Count);
            Assert.AreEqual(4, reverse.Count);
        }
Exemplo n.º 19
0
        public void ReadOnlyReversedTest()
        {
            const int repetition  = 40;
            var       array       = new Deque <int>();
            var       reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < repetition; i++)
            {
                array.Add(i);
            }
            Assert.AreEqual(false, reverseView.IsReadOnly);
            foreach (int s in array)
            {
                Assert.AreEqual(true, reverseView.IsReadOnly);
            }
            Assert.AreEqual(false, reverseView.IsReadOnly);
            foreach (int s in reverseView)
            {
                Assert.AreEqual(true, array.IsReadOnly);
            }
            Assert.AreEqual(false, array.IsReadOnly);
        }
Exemplo n.º 20
0
        public void IndexerSetReversedLargeTest()
        {
            const int repetition  = 10000;
            var       array       = new Deque <int>();
            var       reverseView = DequeTest.GetReverseView(array);

            for (int i = 0; i < repetition; i++)
            {
                array.Add(1);
            }
            reverseView[0] = 3;
            reverseView[repetition - 1] = 2;
            Assert.AreEqual(2, reverseView[repetition - 1]);
            Assert.AreEqual(3, reverseView[0]);
            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                reverseView[-1] = 42;
            });
            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                reverseView[repetition] = 42;
            });
        }
Exemplo n.º 21
0
        public void EnumExceptionsTest()
        {
            var array = new Deque <int> {
                0, 1, 2, 3, 4, 5
            };

            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    array.Add(42);
                }
            });
            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    array.Clear();
                }
            });
            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    array.Insert(0, 42);
                }
            });
            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    array.Remove(42);
                }
            });
            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    array.RemoveAt(0);
                }
            });
            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    array.Reverse();
                }
            });
            var reverseView = DequeTest.GetReverseView(array);

            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    reverseView.Add(42);
                }
            });
            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    reverseView.Clear();
                }
            });
            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    reverseView.Insert(0, 42);
                }
            });
            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    reverseView.Remove(42);
                }
            });
            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    reverseView.RemoveAt(0);
                }
            });
            Assert.ThrowsException <InvalidOperationException>(() =>
            {
                foreach (var item in array)
                {
                    reverseView.Reverse();
                }
            });
        }