public void PopulateWorksSize2() { BinaryArbor1 <int> tree = new BinaryArbor1 <int>(); int[] values = { 1, 2 }; tree.Populate(values); Assert.AreEqual(values[0], tree.Value); Assert.AreEqual(values[1], tree.Right.Value); }
public void PopulateWorksSize1() { BinaryArbor1 <int> tree = new BinaryArbor1 <int>(); int[] values = { 1 }; tree.Populate(values); Assert.AreEqual(values[0], tree.Value); Assert.IsNull(tree.Left); Assert.IsNull(tree.Right); }
public void PopulateWorksSize0() { BinaryArbor1 <int> tree = new BinaryArbor1 <int>(); List <int> values = new List <int> (); tree.Populate(values); Assert.AreEqual(default(int), tree.Value); Assert.IsNull(tree.Left); Assert.IsNull(tree.Right); }
public void PopulateWorksSize4() { BinaryArbor1 <int> tree = new BinaryArbor1 <int>(); int[] values = { 1, 2, 3, 4 }; tree.Populate(values); Assert.AreEqual(values[0], tree.Left.Value); Assert.AreEqual(values[1], tree.Value); Assert.AreEqual(values[2], tree.Right.Value); Assert.AreEqual(values[3], tree.Right.Right.Value); Assert.IsNull(tree.Right.Left); Assert.IsNull(tree.Left.Left); Assert.IsNull(tree.Left.Right); Assert.IsNull(tree.Right.Right.Left); Assert.IsNull(tree.Right.Right.Right); Assert.AreEqual(tree.Left.Parent.Value, tree.Value); Assert.AreEqual(tree.Right.Parent.Value, tree.Value); Assert.AreEqual(tree.Right.Right.Parent.Value, tree.Right.Value); }