/** * Test method for {@link * com.fuerve.whiteboard.milestone2.structures.Tree#setDefaultTraversalMode(com.fuerve.whiteboard.milestone2.structures.Tree.TraversalMode)}. */ @Test public void testSetDefaultTraversalMode() { final Tree<Integer> target = new Tree<Integer>(); target.setDefaultTraversalMode(TraversalMode.INORDER); final Iterator<Integer> iter = target.iterator(); assertTrue(iter instanceof InOrderIterator<?>); }
/** Test method for {@link com.fuerve.whiteboard.milestone2.structures.Tree#iterator()}. */ @Test public void testIterator() { final Tree<Integer> target = new Tree<Integer>(); final Tree<Integer> child1 = new Tree<Integer>(); final Tree<Integer> child2 = new Tree<Integer>(); final Tree<Integer> child1_1 = new Tree<Integer>(); child1_1.setValue(1); child1.setValue(2); child2.setValue(3); target.setValue(4); target.addChild(child1); target.addChild(child2); child1.addChild(child1_1); final Iterator<Integer> iter = target.iterator(); for (int i = 1; i <= 4; i++) { assertEquals(new Integer(i), iter.next()); } }