Ejemplo n.º 1
0
        public void BTreeConstructorTest()
        {
            //check it can be closed and reopened again
            int id = 1;
            int key = 2;

            BTree target = new BTree(id, true);
            target.Insert(key);
            target.Dispose();
            target = new BTree(id, false);
            Assert.AreEqual("I:0:K:3", target.Search(key).ToString());

            //ensure truncation works
            target = new BTree(id, true);
            Assert.AreEqual(null, target.Search(key));
        }
Ejemplo n.º 2
0
        public void InsertTest()
        {
            int id = 1;
            int firstKey = 1;

            BTree target = new BTree(id, true);

            //simple
            target.Insert(firstKey);
            Assert.AreEqual("I:0:K:1;", target.Search(firstKey).ToString());

            //max keys in a single node
            for (int i = 1; i != BTree.MAX_KEYS; ++i)
                target.Insert(i + 1);
            Assert.AreEqual("I:0:K:1,2,3,4,5,6,7;", target.Dump());

            //and one more
            target.Insert(BTree.MAX_KEYS + 1);
            Assert.AreEqual("I:0:K:1,2,3;  I:1:K:4;  I:2:K:5,6,7,8;", target.Dump());
        }
Ejemplo n.º 3
0
 public void SearchTest()
 {
     int id = 0; // TODO: Initialize to an appropriate value
     bool truncate = false; // TODO: Initialize to an appropriate value
     BTree target = new BTree(id, truncate); // TODO: Initialize to an appropriate value
     int k = 0; // TODO: Initialize to an appropriate value
     BTree.NodeIndexPair expected = null; // TODO: Initialize to an appropriate value
     BTree.NodeIndexPair actual;
     actual = target.Search(k);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }