예제 #1
0
        public void TestStructuralInequal()
        {
            var node1 = new TreeNode(1, new TreeNode(3, new TreeNode(4)));
            var node2 = new TreeNode(1, right: new TreeNode(3, right: new TreeNode(4)));

            IsSameTree.IsSame(node1, node2).Should().BeFalse();
        }
예제 #2
0
        public void TestSingleNode()
        {
            var node1 = new TreeNode(1);
            var node2 = new TreeNode(1);
            var node3 = new TreeNode(2);

            IsSameTree.IsSame(node1, node2).Should().BeTrue();
            IsSameTree.IsSame(node1, node3).Should().BeFalse();
        }
예제 #3
0
        public void TestReferences()
        {
            var tree = new TreeNode(1);

            IsSameTree.IsSame(tree, tree).Should().BeTrue();
            IsSameTree.IsSame(null, null).Should().BeTrue();
            IsSameTree.IsSame(tree, null).Should().BeFalse();
            IsSameTree.IsSame(null, tree).Should().BeFalse();
        }
예제 #4
0
        public void TestOnlyLeft()
        {
            var node1 = new TreeNode(1, new TreeNode(3, new TreeNode(4)));
            var node2 = new TreeNode(1, new TreeNode(3, new TreeNode(4)));
            var node3 = new TreeNode(1, new TreeNode(999, new TreeNode(4)));
            var node4 = new TreeNode(1, new TreeNode(3, new TreeNode(999)));

            IsSameTree.IsSame(node1, node2).Should().BeTrue();
            IsSameTree.IsSame(node1, node3).Should().BeFalse();
            IsSameTree.IsSame(node1, node4).Should().BeFalse();
        }
예제 #5
0
        public void TestThreeNodes()
        {
            var node1 = new TreeNode(1, new TreeNode(2), new TreeNode(3));
            var node2 = new TreeNode(1, new TreeNode(2), new TreeNode(3));
            var node3 = new TreeNode(1, new TreeNode(999), new TreeNode(3));
            var node4 = new TreeNode(1, new TreeNode(2), new TreeNode(999));

            IsSameTree.IsSame(node1, node2).Should().BeTrue();
            IsSameTree.IsSame(node1, node3).Should().BeFalse();
            IsSameTree.IsSame(node1, node4).Should().BeFalse();
        }