Beispiel #1
0
        public void HeapHeight_OneElemArray_Test()
        {
            Beap b = new Beap();

            b.Insert(8);

            Assert.AreEqual(0, b.Height);
        }
Beispiel #2
0
        public void FindExistingElem_OneElemArray_Test()
        {
            Beap b = new Beap();

            b.Insert(5);

            Assert.AreEqual(true, b.Find(5));
        }
Beispiel #3
0
        public void HeapSize_OneElem_Test()
        {
            Beap b = new Beap();

            b.Insert(8);

            Assert.AreEqual(1, b.HeapSize);
        }
Beispiel #4
0
        public void DeletingElem_EmptyArray_Test()
        {
            Beap b = new Beap();

            b.Delete(5);

            Assert.AreEqual(0, b.HeapSize);
        }
Beispiel #5
0
        public void Count_OneElem_Test()
        {
            Beap b = new Beap();

            b.Insert(8);

            Assert.AreEqual(0, b.Count(8));
        }
Beispiel #6
0
        public void MaxElem_OneElemArray_Test()
        {
            Beap b = new Beap();

            b.Insert(9999);

            Assert.AreEqual(9999, b.Max());
        }
Beispiel #7
0
        public void MinElem_OneElemArray_Test()
        {
            Beap b = new Beap();

            b.Insert(8);

            Assert.AreEqual(8, b.Min());
        }
Beispiel #8
0
        public void HeapHeight_FullArray_Test()
        {
            Beap b = new Beap();

            b.Insert(8);
            b.Insert(4);
            b.Insert(10);
            b.Insert(2);

            Assert.AreEqual(2, b.Height);
        }
Beispiel #9
0
        public void HelpMethodsTestRand()
        {
            int i = rand.Next() % (int)Math.Sqrt(Int32.MaxValue);
            int j = rand.Next() % (i + 1);

            Assert.AreEqual((i, j), Beap <int> .Index2RowCol(Beap <int> .RowCol2Index(i, j)));

            int k = rand.Next();

            Assert.AreEqual(k, Beap <int> .RowCol2Index(Beap <int> .Index2RowCol(k).Item1, Beap <int> .Index2RowCol(k).Item2));
        }
Beispiel #10
0
        public void FindExistingElem_FullArray_Test(int toFind)
        {
            Beap b = new Beap();

            b.Insert(8);
            b.Insert(4);
            b.Insert(10);
            b.Insert(2);
            b.Insert(7);

            Assert.AreEqual(true, b.Find(toFind));
        }
Beispiel #11
0
        public void MaxElem_FullArray_Test()
        {
            Beap b = new Beap();

            b.Insert(8);
            b.Insert(4);
            b.Insert(10);
            b.Insert(2);
            b.Insert(7);

            Assert.AreEqual(10, b.Max());
        }
Beispiel #12
0
        public void FindAbsentElem_FullArray_Test(int toFind)
        {
            Beap b = new Beap();

            b.Insert(8);
            b.Insert(4);
            b.Insert(10);
            b.Insert(2);
            b.Insert(7);

            Assert.AreEqual(false, b.Find(toFind));
        }
Beispiel #13
0
        public void DeletingElem_LowerRow_Test(int a)
        {
            Beap b = new Beap();

            b.Insert(0);
            b.Insert(-1);
            b.Insert(1);
            b.Insert(2);

            b.Delete(a);

            Assert.AreEqual(3, b.HeapSize);
        }
Beispiel #14
0
        public void HeapSize_AfterClear_Test()
        {
            Beap b = new Beap();

            b.Insert(10);
            b.Insert(4);
            b.Insert(2);
            b.Insert(8);

            b.Clear();

            Assert.AreEqual(0, b.HeapSize);
        }
Beispiel #15
0
        public void DeletingElem_FullArray_Test(int toDelete)
        {
            Beap b = new Beap();

            b.Insert(8);
            b.Insert(4);
            b.Insert(10);
            b.Insert(2);
            b.Insert(7);

            b.Delete(toDelete);

            Assert.AreEqual(4, b.HeapSize);
        }
Beispiel #16
0
        public void Count_FullArray_Test()
        {
            Beap b = new Beap();

            b.Insert(10);
            b.Insert(15);
            b.Insert(25);
            b.Insert(14);
            b.Insert(19);
            b.Insert(13);
            b.Insert(20);
            b.Insert(50);
            b.Insert(22);

            Assert.AreEqual(2, b.Count(14));
        }
Beispiel #17
0
        public void DeletingElem_ForHeightDecrease_Test(int a)
        {
            Beap b = new Beap();

            b.Insert(10);
            b.Insert(15);
            b.Insert(14);
            b.Insert(25);
            b.Insert(13);
            b.Insert(19);
            b.Insert(20);

            b.Delete(a);

            Assert.AreEqual(6, b.HeapSize);
        }
Beispiel #18
0
        public void HeapSize_Big_Insert_Test()
        {
            Beap b = new Beap();

            b.Insert(10);
            b.Insert(15);
            b.Insert(25);
            b.Insert(14);
            b.Insert(19);
            b.Insert(13);
            b.Insert(20);
            b.Insert(50);
            b.Insert(22);

            Assert.AreEqual(9, b.HeapSize);
        }
Beispiel #19
0
        public void SearchTest1()
        {
            var beap = new Beap <int>();

            int[] values = new int[] { -5, 0, -45, 1, 15 };
            for (int i = 0; i < values.Length; ++i)
            {
                beap.Insert(values[i]);
            }

            Assert.AreEqual(beap[beap.Search(15)], 15, "Index of 15 should be 0");
            Assert.AreEqual(beap[beap.Search(0)], 0, "Index of 0 should be 1");
            Assert.AreEqual(beap[beap.Search(1)], 1, "Index of 1 should be 2");
            Assert.AreEqual(beap[beap.Search(-5)], -5, "Index of -5 should be 3");
            Assert.AreEqual(beap[beap.Search(-45)], -45, "Index of -45 should be 4");

            Assert.AreEqual(-1, beap.Search(-2), "Should not have find value -1 in beap");
        }
Beispiel #20
0
        public void DeletingElem_ForBranches_Test(int a, int q, int c, int d)
        {
            Beap b = new Beap();

            b.Insert(10);
            b.Insert(15);
            b.Insert(14);
            b.Insert(25);
            b.Insert(13);
            b.Insert(19);
            b.Insert(20);
            b.Insert(50);
            b.Insert(22);

            b.Delete(a);
            b.Delete(q);
            b.Delete(c);
            b.Delete(d);

            Assert.AreEqual(5, b.HeapSize);
        }
Beispiel #21
0
        public void MaxElem_EmptyArray_Test()
        {
            Beap b = new Beap();

            Assert.AreEqual(0, b.Max());
        }
Beispiel #22
0
 public void HelpMethodsTest3()
 {
     Assert.AreEqual(3, Beap <int> .RowCol2Index(2, 0));
     Assert.AreEqual((2, 0), Beap <int> .Index2RowCol(3));
 }
Beispiel #23
0
 public void HelpMethodsTest2()
 {
     Assert.AreEqual(4, Beap <int> .RowCol2Index(2, 1));
     Assert.AreEqual((2, 1), Beap <int> .Index2RowCol(4));
 }
Beispiel #24
0
 public void HelpMethodsTest1()
 {
     Assert.AreEqual(5, Beap <int> .RowCol2Index(2, 2));
     Assert.AreEqual((2, 2), Beap <int> .Index2RowCol(5));
 }
Beispiel #25
0
        public void HeapSize_EmptyArray_Test()
        {
            Beap b = new Beap();

            Assert.AreEqual(0, b.HeapSize);
        }
Beispiel #26
0
        public void Count_EmptyArray_Test()
        {
            Beap b = new Beap();

            Assert.AreEqual(0, b.Count(0));
        }