public void NonRootLL() { t = new Models.Spells.SpellTree.RBTree(s5);//e t.insert(s6); t.insert(s4); t.insert(s3); RootCheck(t); BlackCheck(t.Root.Right); BlackCheck(t.Root.Left); RedCheck(t.Root.Left.Left); Assert.AreEqual("e", t.Root.Value.Name); Assert.AreEqual("f", t.Root.Right.Value.Name); Assert.IsNull(t.Root.Right.Left); Assert.IsNull(t.Root.Right.Right); Assert.AreEqual("d", t.Root.Left.Value.Name); Assert.AreEqual("c", t.Root.Left.Left.Value.Name); Assert.IsNull(t.Root.Left.Right); t.insert(s2); Assert.AreEqual("e", t.Root.Value.Name); Assert.AreEqual("f", t.Root.Right.Value.Name); Assert.AreEqual("c", t.Root.Left.Value.Name); Assert.AreEqual("d", t.Root.Left.Right.Value.Name); Assert.AreEqual("b", t.Root.Left.Left.Value.Name); BlackCheck(t.Root); BlackCheck(t.Root.Right); RedCheck(t.Root.Left.Right); RedCheck(t.Root.Left.Left); BlackCheck(t.Root.Left); }
public void printTreeTest_ThreeElements() { t = new Models.Spells.SpellTree.RBTree(s2); t.insert(s1); t.insert(s3); t.printTree(); Assert.AreEqual("a b c ", t.Order); }
public void UncleRecolorationTestLR() { t = new Models.Spells.SpellTree.RBTree(s6); t.insert(s3); t.insert(s7); t.insert(s4);// grandchild: LR uncle: R Assert.AreEqual((int)Models.Spells.SpellTree.color.black, t.Root.Left.Color); Assert.AreEqual((int)Models.Spells.SpellTree.color.black, t.Root.Right.Color); Assert.AreEqual((int)Models.Spells.SpellTree.color.red, t.Root.Left.Right.Color); Assert.AreEqual((int)Models.Spells.SpellTree.color.black, t.Root.Color); }
public void lineRotationLeftTest() { t = new Models.Spells.SpellTree.RBTree(s5); //e t.insert(s4); //d t.insert(s3); //c Assert.AreEqual("d", t.Root.Value.Name); Assert.AreEqual("c", t.Root.Left.Value.Name); Assert.AreEqual("e", t.Root.Right.Value.Name); Assert.AreEqual((int)Models.Spells.SpellTree.color.black, t.Root.Color); Assert.AreEqual((int)Models.Spells.SpellTree.color.red, t.Root.Left.Color); Assert.AreEqual((int)Models.Spells.SpellTree.color.red, t.Root.Right.Color); }
public void lineRotationRightTest() { t = new Models.Spells.SpellTree.RBTree(s1); t.insert(s2); t.insert(s3); Assert.AreEqual("b", t.Root.Value.Name); Assert.AreEqual("a", t.Root.Left.Value.Name); Assert.AreEqual("c", t.Root.Right.Value.Name); Assert.AreEqual((int)Models.Spells.SpellTree.color.black, t.Root.Color); Assert.AreEqual((int)Models.Spells.SpellTree.color.red, t.Root.Left.Color); Assert.AreEqual((int)Models.Spells.SpellTree.color.red, t.Root.Right.Color); }
public void TriangleRotationLRTest() { t = new Models.Spells.SpellTree.RBTree(s5); //e RootCheck(t); t.insert(s3); //c t.insert(s4); //d Assert.AreEqual("d", t.Root.Value.Name); Assert.AreEqual("c", t.Root.Left.Value.Name); Assert.AreEqual("e", t.Root.Right.Value.Name); Assert.AreEqual((int)Models.Spells.SpellTree.color.black, t.Root.Color); Assert.AreEqual((int)Models.Spells.SpellTree.color.red, t.Root.Left.Color); Assert.AreEqual((int)Models.Spells.SpellTree.color.red, t.Root.Right.Color); }
public void RootRecolorationTest() { t = new Models.Spells.SpellTree.RBTree(s2); Assert.AreEqual((int)Models.Spells.SpellTree.color.black, t.Root.Color); t = new Models.Spells.SpellTree.RBTree(); t.insert(s2); Assert.AreEqual((int)Models.Spells.SpellTree.color.black, t.Root.Color); }
public void PrintTreeTest_6_ordered() { t = new Models.Spells.SpellTree.RBTree(); String orderTest = ""; foreach (Spell spell in spellList()) { t.insert(spell); orderTest += spell.Name + " "; t.Order = ""; t.printTree(); Assert.AreEqual(orderTest, t.Order); } t.Order = ""; t.printTree(); }
public void PrintTreeTest_8_ReverseOrdered() { t = new Models.Spells.SpellTree.RBTree(); String orderTest = ""; List <Models.Spells.Spell> spells = spellList(); spells.Reverse(); foreach (Spell spell in spells) { t.insert(spell); } NodeCheck(t.Root, 1, "e"); NodeCheck(t.Root.Right, 0, "g"); NodeCheck(t.Root.Right.Left, 1, "f"); NodeCheck(t.Root.Right.Right, 1, "h"); NodeCheck(t.Root.Left, 0, "c"); NodeCheck(t.Root.Left.Right, 1, "d"); NodeCheck(t.Root.Left.Left, 1, "b"); NodeCheck(t.Root.Left.Left.Left, 0, "a"); }
public void PrintTreeTest_8_ordered() { t = new Models.Spells.SpellTree.RBTree(); String orderTest = ""; foreach (Spell spell in spellList()) { t.insert(spell); orderTest += spell.Name + " "; t.Order = ""; t.printTree(); Assert.AreEqual(orderTest, t.Order); } NodeCheck(t.Root, 1, "d"); NodeCheck(t.Root.Right, 0, "f"); NodeCheck(t.Root.Right.Left, 1, "e"); NodeCheck(t.Root.Right.Right, 1, "g"); NodeCheck(t.Root.Right.Right.Right, 0, "h"); NodeCheck(t.Root.Left, 0, "b"); NodeCheck(t.Root.Left.Right, 1, "c"); NodeCheck(t.Root.Left.Left, 1, "a"); }