Exemple #1
0
        public void TestSecondIsNull()
        {
            TreeNode first  = new TreeNode(1);
            TreeNode second = null;

            Assert.IsFalse(SubstructureInTree.Process(first, second));
        }
Exemple #2
0
        public void TestOnlyOneNode()
        {
            TreeNode first  = new TreeNode(1);
            TreeNode second = new TreeNode(1);

            Assert.IsTrue(SubstructureInTree.Process(first, second));
        }
Exemple #3
0
        public void TestWithSameTree()
        {
            TreeNode first = new TreeNode(8);

            first.Left             = new TreeNode(8);
            first.Left.Left        = new TreeNode(9);
            first.Left.Right       = new TreeNode(2);
            first.Left.Right.Left  = new TreeNode(4);
            first.Left.Right.Right = new TreeNode(7);
            first.Right            = new TreeNode(7);

            TreeNode second = Helper.Clone(first);

            Assert.IsTrue(SubstructureInTree.Process(first, second));
        }
Exemple #4
0
        public void TestSubTreeInNoLeftChildTree()
        {
            TreeNode first = new TreeNode(8);

            first.Right                   = new TreeNode(8);
            first.Right.Right             = new TreeNode(9);
            first.Right.Right.Right       = new TreeNode(2);
            first.Right.Right.Right.Right = new TreeNode(5);

            TreeNode second = new TreeNode(8);

            second.Right       = new TreeNode(9);
            second.Right.Right = new TreeNode(2);

            Assert.IsTrue(SubstructureInTree.Process(first, second));
        }
Exemple #5
0
        public void TestNotSubTreeInNoRightChildTree()
        {
            TreeNode first = new TreeNode(8);

            first.Left                = new TreeNode(8);
            first.Left.Left           = new TreeNode(9);
            first.Left.Left.Left      = new TreeNode(3);
            first.Left.Left.Left.Left = new TreeNode(5);

            TreeNode second = new TreeNode(8);

            second.Left      = new TreeNode(9);
            second.Left.Left = new TreeNode(2);

            Assert.IsFalse(SubstructureInTree.Process(first, second));
        }
Exemple #6
0
        public void TestSubTreeInNotCompleteTree()
        {
            TreeNode first = new TreeNode(8);

            first.Left             = new TreeNode(8);
            first.Left.Left        = new TreeNode(9);
            first.Left.Right       = new TreeNode(2);
            first.Left.Right.Left  = new TreeNode(4);
            first.Left.Right.Right = new TreeNode(7);
            first.Right            = new TreeNode(7);

            TreeNode second = new TreeNode(8);

            second.Left  = new TreeNode(9);
            second.Right = new TreeNode(2);

            Assert.IsTrue(SubstructureInTree.Process(first, second));
        }
Exemple #7
0
 public void TestBothNull()
 {
     Assert.IsFalse(SubstructureInTree.Process(null, null));
 }