Skip to content

Instantly share code, notes, and snippets.

@calindotgabriel
Created June 30, 2015 17:32
Show Gist options
  • Save calindotgabriel/d13aff9710f3f66dc2ec to your computer and use it in GitHub Desktop.
Save calindotgabriel/d13aff9710f3f66dc2ec to your computer and use it in GitHub Desktop.
package test;
import domain.ChildrenOccupiedException;
import domain.Controller;
import junit.framework.TestCase;
import org.junit.Test;
import tree.BinaryTree;
import java.util.Iterator;
import static junit.framework.Assert.assertTrue;
import static junit.framework.TestCase.assertEquals;
/**
* tree.BinaryTree Tester.
*
* @author <Authors name>
* @since <pre>Jun 29, 2015</pre>
* @version 1.0
*/
public class BinaryTreeTest {
@Test
public void testAcces() {
BinaryTree<String> rootTree = getDummyTree();
assertEquals("Right Doggie", rootTree.right().element());
}
@Test
public void testIterator() {
BinaryTree<String> rootTree = getDummyTree();
for (BinaryTree tree : rootTree) {
System.out.println(tree.element());
}
}
private BinaryTree<String> getDummyTree() {
BinaryTree<String> rootTree = new BinaryTree<String>();
rootTree.createLeaf("AncestorDog");
BinaryTree<String> leftTree = new BinaryTree<String>();
leftTree.createLeaf("Left Doggie");
rootTree.addSubLeft(leftTree);
BinaryTree<String> rightTree = new BinaryTree<String>();
rightTree.createLeaf("Right Doggie");
rootTree.addSubRight(rightTree);
BinaryTree<String> leftleftTree = new BinaryTree<String>();
leftleftTree.createLeaf("Leftest Doggie");
leftTree.addSubLeft(leftleftTree);
return rootTree;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment