示例#1
0
  @Test
  public void testInOrderIteratorSingleValue() {
    final Tree<Integer> target = new Tree<Integer>();

    target.setValue(1);

    final Iterator<Integer> iter = target.inOrderIterator();
    assertEquals(new Integer(1), iter.next());
    assertFalse(iter.hasNext());
  }
示例#2
0
  /** Test method for {@link com.fuerve.whiteboard.milestone2.structures.Tree#inOrderIterator()}. */
  @Test
  public void testInOrderIterator() {
    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);
    target.setValue(3);
    child2.setValue(4);

    target.addChild(child1);
    target.addChild(child2);
    child1.addChild(child1_1);

    final Iterator<Integer> iter = target.inOrderIterator();
    for (int i = 1; i <= 4; i++) {
      assertEquals(new Integer(i), iter.next());
    }
  }