BinaryTreeEquals { public boolean areEqualsRecursive(BinaryNode tree1, BinaryNode tree2) { validateInput(tree1, tree2); return areEqualsInner(tree1, tree2); }  boolean areEqualsRecursive(BinaryNode tree1, BinaryNode tree2); boolean areEqualsIterative(BinaryNode<Integer> tree1, BinaryNode<Integer> tree2);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptTwoNullTreesRecursive() { binaryTreeEquals.areEqualsRecursive(null, null); }
@Test public void shouldReturnFalseIfOneIsNullRecursive() { BinaryNode<Integer> root = new BinaryNode<Integer>(0); assertFalse(binaryTreeEquals.areEqualsRecursive(root, null)); }
@Test public void shouldReturnTrueIfBothElementsAreEqualsEvenIfJustContainsOneElementRecursive() { BinaryNode<Integer> root = new BinaryNode<Integer>(0); BinaryNode<Integer> root1 = new BinaryNode<Integer>(0); assertTrue(binaryTreeEquals.areEqualsRecursive(root, root1)); }
@Test public void shouldReturnFalseIfTreesAreNotEqualsRecursive() { BinaryNode<Integer> root = new BinaryNode<Integer>(0); BinaryNode<Integer> n1 = new BinaryNode<Integer>(1); root.setLeft(n1); BinaryNode<Integer> root1 = new BinaryNode<Integer>(0); assertFalse(binaryTreeEquals.areEqualsRecursive(root, root1)); }
@Test public void shouldReturnTrueIfTreesAreEqualsRecursive() { BinaryNode<Integer> root = new BinaryNode<Integer>(0); BinaryNode<Integer> n1 = new BinaryNode<Integer>(1); BinaryNode<Integer> n2 = new BinaryNode<Integer>(2); BinaryNode<Integer> n3 = new BinaryNode<Integer>(3); root.setLeft(n1); root.setRight(n2); n1.setLeft(n3); BinaryNode<Integer> root1 = new BinaryNode<Integer>(0); BinaryNode<Integer> n11 = new BinaryNode<Integer>(1); BinaryNode<Integer> n21 = new BinaryNode<Integer>(2); BinaryNode<Integer> n31 = new BinaryNode<Integer>(3); root.setLeft(n11); root.setRight(n21); n1.setLeft(n31); assertFalse(binaryTreeEquals.areEqualsRecursive(root, root1)); }