public void TreeWithOnlyOneNode() { BinaryTreeNode <int> root = new BinaryTreeNode <int>(23); MirrorOfBinaryTree.GetMirror(root); Assert.Equal(23, root.Value); }
public void InvalidInput() { BinaryTreeNode <int> root = null; MirrorOfBinaryTree.GetMirror(root); Assert.Null(root); }
public void TestNull() { TreeNode root = null; MirrorOfBinaryTree.Process(root); Assert.IsNull(root); root = null; MirrorOfBinaryTree.ProcessRecursively(root); Assert.IsNull(root); }
public void TestOnlyOneNode() { TreeNode root = new TreeNode(1); TreeNode expected = new TreeNode(1); MirrorOfBinaryTree.Process(root); Assert.IsTrue(Helper.CompareBinaryTree(expected, root)); root = new TreeNode(1); MirrorOfBinaryTree.ProcessRecursively(root); Assert.IsTrue(Helper.CompareBinaryTree(expected, root)); }
public void TestNoRightChildTree() { TreeNode root = Helper.CreateTree(TreeType.NoRightChildTree); TreeNode expected = Helper.CreateTree(TreeType.NoLeftChildTree); MirrorOfBinaryTree.Process(root); Assert.IsTrue(Helper.CompareBinaryTree(expected, root)); root = Helper.CreateTree(TreeType.NoRightChildTree); MirrorOfBinaryTree.ProcessRecursively(root); Assert.IsTrue(Helper.CompareBinaryTree(expected, root)); }
public void TreeWithOnlyLeftNode() { BinaryTreeNode <int> root = new BinaryTreeNode <int>(23); root.Left = new BinaryTreeNode <int>(65); root.Left.Left = new BinaryTreeNode <int>(12); root.Left.Left.Left = new BinaryTreeNode <int>(120); MirrorOfBinaryTree.GetMirror(root); Assert.Equal(23, root.Value); Assert.Equal(65, root.Right.Value); Assert.Equal(12, root.Right.Right.Value); Assert.Equal(120, root.Right.Right.Right.Value); }
public void NormalTest() { BinaryTreeNode <int> root = new BinaryTreeNode <int>(23); root.Left = new BinaryTreeNode <int>(65); root.Right = new BinaryTreeNode <int>(12); root.Left.Left = new BinaryTreeNode <int>(98); root.Left.Right = new BinaryTreeNode <int>(45); root.Right.Right = new BinaryTreeNode <int>(111); MirrorOfBinaryTree.GetMirror(root); Assert.Equal(23, root.Value); Assert.Equal(12, root.Left.Value); Assert.Equal(111, root.Left.Left.Value); Assert.Equal(65, root.Right.Value); Assert.Equal(98, root.Right.Right.Value); Assert.Equal(45, root.Right.Left.Value); }
public void TestCompleteTree() { TreeNode root = Helper.CreateTree(TreeType.CompleteTree); TreeNode expected = new TreeNode(1); expected.Left = new TreeNode(3); expected.Left.Left = new TreeNode(7); expected.Left.Right = new TreeNode(6); expected.Right = new TreeNode(2); expected.Right.Left = new TreeNode(5); expected.Right.Right = new TreeNode(4); MirrorOfBinaryTree.Process(root); Assert.IsTrue(Helper.CompareBinaryTree(expected, root)); root = Helper.CreateTree(TreeType.CompleteTree); MirrorOfBinaryTree.ProcessRecursively(root); Assert.IsTrue(Helper.CompareBinaryTree(expected, root)); }