Esempio n. 1
0
        public void EnqueueDequeueTail()
        {
            var deque = new Deque<int>();
              Assert.That(() => deque.DequeueTail(), Throws.TypeOf<InvalidOperationException>());
              deque.EnqueueHead(1);
              Assert.AreEqual(1, deque.Count);
              Assert.AreEqual(1, deque.DequeueTail());
              Assert.AreEqual(0, deque.Count);

              deque = new Deque<int>(new[] { 2, 3, 4 });
              Assert.AreEqual(4, deque.DequeueTail());
              deque.EnqueueTail(0);
              Assert.AreEqual(3, deque.Count);
              Assert.AreEqual(0, deque.DequeueTail());
              Assert.AreEqual(2, deque.Count);
        }
Esempio n. 2
0
        public void Tail()
        {
            var deque = new Deque<int>();
              Assert.That(() => { int i = deque.Tail; }, Throws.TypeOf<InvalidOperationException>());
              Assert.That(() => { deque.Tail = 0; }, Throws.TypeOf<InvalidOperationException>());

              deque.EnqueueHead(123);
              Assert.AreEqual(123, deque.Tail);

              deque.EnqueueTail(234);
              Assert.AreEqual(234, deque.Tail);

              deque.EnqueueHead(345);
              Assert.AreEqual(234, deque.Tail);

              deque.Tail = 1;
              Assert.AreEqual(1, deque.Tail);

              deque.DequeueHead();
              Assert.AreEqual(1, deque.Tail);

              deque.DequeueTail();
              Assert.AreEqual(123, deque.Head);
        }
Esempio n. 3
0
        public void Count()
        {
            var deque = new Deque<int>();
              Assert.AreEqual(0, deque.Count);

              deque.EnqueueHead(1);
              deque.EnqueueHead(0);
              deque.EnqueueTail(2);
              deque.EnqueueTail(3);
              deque.EnqueueTail(4);
              deque.DequeueHead();
              deque.DequeueTail();
              Assert.AreEqual(3, deque.Count);

              deque.Clear();
              Assert.AreEqual(0, deque.Count);
        }