Esempio n. 1
0
        public void TestOrderPushBackPopFront()
        {
            var d = new Deq <int>();

            d.PushBack(1);
            d.PushBack(2);
            d.PushBack(3);
            d.PushBack(4);

            Assert.AreEqual(1, d.PopFront());
            Assert.AreEqual(2, d.PopFront());
            Assert.AreEqual(3, d.PopFront());
            Assert.AreEqual(4, d.PopFront());
        }
Esempio n. 2
0
        public void TestTwoItems()
        {
            const int val1 = 100500;
            const int val2 = 100600;
            var       d    = new Deq <int>();

            d.PushBack(val1);
            d.PushBack(val2);
            d = Sorter.Sort2(d);

            Assert.IsFalse(d.Empty);
            Assert.AreEqual(2, d.Count);
            Assert.AreEqual(val1, d.PopFront());
            Assert.AreEqual(val2, d.PopFront());
        }
Esempio n. 3
0
        public void TestPushBackPopFrontOne()
        {
            const int val = 100503;
            var       d   = new Deq <int>();

            d.PushBack(val);
            Assert.AreEqual(val, d.PopFront());
            Assert.IsTrue(d.Empty);
            Assert.AreEqual(0, d.Count);
        }
Esempio n. 4
0
        public void TestSetDeqElementByPosition()
        {
            var d = new Deq <int>();

            d.PushFront(1);
            d.SetDeqElementByPosition(0, 2);

            Assert.IsFalse(d.Empty);
            Assert.AreEqual(1, d.Count);
            Assert.AreEqual(2, d.GetDeqElementByPosition(0));
            Assert.AreEqual(2, d.PopFront());
        }
Esempio n. 5
0
        public void TestSortMoreItems()
        {
            int[] data = new[] {100500, 100600, 1, 1999, 200500, 1000, 100, 5};

            var d = new Deq<int>();
            foreach (var v in data) {
                d.PushBack(v);
            }

            d = Sorter.Sort2(d);

            Assert.IsFalse(d.Empty);
            Assert.AreEqual(data.Length, d.Count);

            Array.Sort(data);

            foreach (var v in data) {
                Assert.AreEqual(v, d.PopFront());
            }
        }
Esempio n. 6
0
        public void TestSortSortedMoreItems()
        {
            int[] data = new[] { 100500, 100600, 1, 1999, 200500, 1000, 100, 5 };
            Array.Sort(data);

            var d = new Deq <int>();

            foreach (var v in data)
            {
                d.PushBack(v);
            }

            d = Sorter.Sort2(d);

            Assert.IsFalse(d.Empty);
            Assert.AreEqual(data.Length, d.Count);

            foreach (var v in data)
            {
                Assert.AreEqual(v, d.PopFront());
            }
        }
Esempio n. 7
0
        public void TestThreeItems()
        {
            const int val1 = 100500;
            const int val2 = 100600;
            const int val3 = 100700;
            var d = new Deq<int>();
            d.PushBack(val2);
            d.PushBack(val3);
            d.PushBack(val1);
            d = Sorter.Sort2(d);

            Assert.IsFalse(d.Empty);
            Assert.AreEqual(3, d.Count);
            Assert.AreEqual(val1, d.PopFront());
            Assert.AreEqual(val2, d.PopFront());
            Assert.AreEqual(val3, d.PopFront());
        }
Esempio n. 8
0
        public void TestEmptyPopFront()
        {
            var d = new Deq <int>();

            d.PopFront();
        }
Esempio n. 9
0
        public void TestEmptyPopFront()
        {
            var d = new Deq<int>();

            d.PopFront();
        }
Esempio n. 10
0
        public void TestSetDeqElementByPosition()
        {
            var d = new Deq<int>();

            d.PushFront(1);
            d.SetDeqElementByPosition(0, 2);

            Assert.IsFalse(d.Empty);
            Assert.AreEqual(1, d.Count);
            Assert.AreEqual(2, d.GetDeqElementByPosition(0));
            Assert.AreEqual(2, d.PopFront());
        }
Esempio n. 11
0
        public void TestPushBackPopFrontOne()
        {
            const int val = 100503;
            var d = new Deq<int>();

            d.PushBack(val);
            Assert.AreEqual(val, d.PopFront());
            Assert.IsTrue(d.Empty);
            Assert.AreEqual(0, d.Count);
        }
Esempio n. 12
0
        public void TestOrderPushFrontPopFront()
        {
            var d = new Deq<int>();

            d.PushFront(1);
            d.PushFront(2);
            d.PushFront(3);
            d.PushFront(4);

            Assert.AreEqual(4, d.PopFront());
            Assert.AreEqual(3, d.PopFront());
            Assert.AreEqual(2, d.PopFront());
            Assert.AreEqual(1, d.PopFront());
        }