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

    target.setValue(1);

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

    target.setValue(1);
    child1.setValue(2);
    child1_1.setValue(3);
    child2.setValue(4);

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

    final Iterator<Integer> iter = target.postorderIterator();
    for (int i = 1; i <= 4; i++) {
      assertEquals(new Integer(i), iter.next());
    }
  }
示例#3
0
  /** Test method for {@link com.fuerve.whiteboard.milestone2.structures.Tree#getChildAt(int)}. */
  @Test
  public void testGetChildAt() {
    final Tree<Integer> target = new Tree<Integer>();
    final Tree<Integer> child = new Tree<Integer>();
    child.setValue(1);

    target.addChild(new Tree<Integer>());
    target.addChild(new Tree<Integer>());
    target.addChild(child);
    target.addChild(new Tree<Integer>());

    assertEquals(child, target.getChildAt(2));
  }
示例#4
0
 /** Test method for {@link com.fuerve.whiteboard.milestone2.structures.Tree#getValue()}. */
 @Test
 public void testGetSetValue() {
   final Tree<Integer> target = new Tree<Integer>();
   target.setValue(1);
   assertEquals(new Integer(1), target.getValue());
 }