public void EnumerateInOrderHandlesTinyTree() { PointerBackedBinaryTree <int> testTree = new PointerBackedBinaryTree <int>(); testTree.Root = new PointerBackedBinaryTreeNode <int>(1, null); testTree.Root.Left = new PointerBackedBinaryTreeNode <int>(2, testTree.Root); testTree.Root.Right = new PointerBackedBinaryTreeNode <int>(3, testTree.Root); CollectionAssert.AreEqual(new int[] { 2, 1, 3 }, testTree.EnumerateInOrder()); }
public void EnumerateInOrderHandlesLargeTree() { PointerBackedBinaryTree <int> testTree = new PointerBackedBinaryTree <int>(); testTree.Root = new PointerBackedBinaryTreeNode <int>(1, null); testTree.Root.Right = new PointerBackedBinaryTreeNode <int>(3, testTree.Root); testTree.Root.Right.Left = new PointerBackedBinaryTreeNode <int>(2, testTree.Root.Right); testTree.Root.Right.Right = new PointerBackedBinaryTreeNode <int>(5, testTree.Root.Right); testTree.Root.Right.Right.Left = new PointerBackedBinaryTreeNode <int>(4, testTree.Root.Right.Right); testTree.Root.Right.Right.Right = new PointerBackedBinaryTreeNode <int>(6, testTree.Root.Right.Right); CollectionAssert.AreEqual(new int[] { 1, 2, 3, 4, 5, 6 }, testTree.EnumerateInOrder()); }