Beispiel #1
0
            public void insert_20_maxsize_15_items()
            {
                SimpleMaxPQ pq = new SimpleMaxPQ(15); // initial capacity of 10;
                for (int i = 0; i < 20; i++)
                    pq.insert(i); // add 0, 1, 2, 3, 4;

                Assert.AreEqual(19, pq.max(), "B1");
                Assert.AreEqual(20, pq.size(), "B2");

                pq.insert(22);
                Assert.AreEqual(21, pq.size(), "B3");
            }
Beispiel #2
0
            public void insert_5_items()
            {
                SimpleMaxPQ pq = new SimpleMaxPQ(10); // initial capacity of 10;
                for (int i = 0; i < 5; i++)
                    pq.insert(i); // add 0, 1, 2, 3, 4;

                Assert.AreEqual(4, pq.max(), "A1");
                Assert.AreEqual(5, pq.size(), "A2");

                pq.insert(7);
                Assert.AreEqual(6, pq.size(), "A3");
            }
Beispiel #3
0
            public void insert_20_maxsize_15_items_reverse()
            {
                SimpleMaxPQ pq = new SimpleMaxPQ(15); // initial capacity of 15;
                for (int i = 20; i > 0; i--)
                    pq.insert(i); 

                Assert.AreEqual(19, pq.delMax(), "EC1");
                Assert.AreEqual(19, pq.size(), "EC2");

                pq.insert(5);
                Assert.AreEqual(18, pq.delMax(), "E4");
                Assert.AreEqual(20, pq.size(), "E5");
            }
Beispiel #4
0
        public void size_insertAndDelItems_trueIfSizeIsRight()
        {
            SimpleMaxPQ m = new SimpleMaxPQ(10);
            for (int i = 0; i < 10; i++)
            {
                Assert.IsTrue(m.size() == i, "Size function not working properly");
                m.insert(i);
            }

            for (int i=10; i > 0; i--)
            {
                Assert.AreEqual(i, m.size(), "Size function after deleting not working correctly.");
                m.delMin();
            }
        }
Beispiel #5
0
 public void size_insertItems_trueIfSizeIsRight()
 {
     SimpleMaxPQ m = new SimpleMaxPQ(10);
     for (int i=0; i < 10; i++)
     {
         Assert.IsTrue(m.size() == i, "Size function not working properly");
         m.insert(i);
     }
 }