예제 #1
0
        public static void CanCloneTree()
        {
            const int treeSize = 500;
            Node      root     = TreeGenerator.GenerateTree(treeSize);

            Node cloned = TreeGenerator.CloneTree(root);

            Assert.True(MerkleExercise.CompareTrees(root, cloned));
        }
예제 #2
0
        public static void CanDetectSubtrees()
        {
            const int treeSize    = 500;
            Node      bigTreeRoot = TreeGenerator.GenerateTree(treeSize);

            Node randomBigTreeNode = TreeGenerator.PickRandomNode(bigTreeRoot);

            Node subtree = TreeGenerator.CloneTree(randomBigTreeNode);

            Assert.True(MerkleExercise.IsSubtree(bigTreeRoot, subtree));
        }
예제 #3
0
        public static void CanFiddleWithTree()
        {
            const int treeSize = 500;
            Node      root     = TreeGenerator.GenerateTree(treeSize);

            Node cloned = TreeGenerator.CloneTree(root);

            TreeGenerator.FiddleWithTree(cloned);

            // a fiddled tree should never be identical
            Assert.False(MerkleExercise.CompareTrees(root, cloned));
        }