Exemplo n.º 1
0
        public void Test_EndqueueFirst()
        {
            MyDeque <string> deq = new MyDeque <string>();

            deq.EnqueueFirst("Первый");
            deq.EnqueueFirst("Второй");
            deq.EnqueueFirst("Третий");
            Assert.AreEqual(deq.Count, 3);
            Assert.AreNotEqual(deq.PeekFirst(), deq.PeekLast());
        }
Exemplo n.º 2
0
        public void Test_Contains()
        {
            MyDeque <int> deq = new MyDeque <int>();

            deq.EnqueueFirst(1);
            deq.EnqueueFirst(2);
            deq.EnqueueFirst(3);
            deq.EnqueueFirst(4);
            Assert.AreEqual(deq.Contains(2), true);
        }
Exemplo n.º 3
0
        public void Test_Count()
        {
            MyDeque <int> deq = new MyDeque <int>();

            deq.EnqueueFirst(1);
            deq.EnqueueFirst(2);
            deq.EnqueueFirst(3);
            deq.EnqueueFirst(4);
            Assert.AreEqual(deq.Count, 4);

            deq.Clear();
            Assert.AreEqual(deq.Count, 0);
        }
Exemplo n.º 4
0
        public void Test_IsEmpty()
        {
            MyDeque <int> deq = new MyDeque <int>();

            Assert.AreEqual(deq.IsEmpty, true);

            deq.EnqueueFirst(1);
            Assert.AreEqual(deq.IsEmpty, false);
        }
Exemplo n.º 5
0
        public void Test_CompareTo()
        {
            MyDeque <int> deq = new MyDeque <int>();

            deq.EnqueueLast(1);
            deq.EnqueueLast(2);
            deq.EnqueueLast(3);
            deq.EnqueueLast(4);

            MyDeque <int> deq2 = new MyDeque <int>();

            deq2.EnqueueFirst(2);
            deq2.EnqueueFirst(2);

            Assert.AreEqual(deq.CompareTo(deq2), 1);

            deq2.EnqueueFirst(2);
            deq2.EnqueueFirst(2);

            Assert.AreEqual(deq.CompareTo(deq2), 0);

            deq2.EnqueueFirst(2);
            deq2.EnqueueFirst(2);

            Assert.AreEqual(deq.CompareTo(deq2), -1);
        }