コード例 #1
0
        private void NullRootTest(ICommonAncestorFinder commonAncestorFinder)
        {
            BinaryTreeNode <int> root     = null;
            BinaryTreeNode <int> node1    = new BinaryTreeNode <int>(9);
            BinaryTreeNode <int> node2    = new BinaryTreeNode <int>(10);
            BinaryTreeNode <int> result   = commonAncestorFinder.FindCommonAncestor(root, node1, node2);
            BinaryTreeNode <int> expected = null;

            Assert.AreEqual(expected, result);
        }
コード例 #2
0
        private void AncestorFoundTest(ICommonAncestorFinder commonAncestorFinder)
        {
            BinaryTreeNode <int> root     = BuildBinaryTree();
            BinaryTreeNode <int> node1    = root.Left.Right;
            BinaryTreeNode <int> node2    = root.Left.Left.Right;
            BinaryTreeNode <int> expected = root.Left;
            BinaryTreeNode <int> result   = commonAncestorFinder.FindCommonAncestor(root, node1, node2);

            Assert.AreEqual(expected, result);
        }
コード例 #3
0
 private void RunTests(ICommonAncestorFinder commonAncestorFinder)
 {
     NullRootTest(commonAncestorFinder);
     NullNodesTest(commonAncestorFinder);
     AncestorFoundTest(commonAncestorFinder);
 }