Exemplo n.º 1
0
  @Test
  public void testCeiling() {

    // build tree

    // ceiling on null
    assertNull(this.tree.ceiling(3));

    /* Build Tree
     *            15
     *      /           \
     *     7            23
     *   /   \        /     \
     *  3     11     19      27
     * / \   / \    /  \    /  \
     *1   5 9   13 17   21 25   29
     */
    for (int i = 1; i < 30; i += 2) {
      this.tree.add(i);
      this.test.add(i);
    }

    for (int i = 1; i < 30; i += 2) {
      assertTrue(i == tree.ceiling(i));
    }

    for (int i = 0; i < 30; i += 2) {
      assertTrue(i + 1 == tree.ceiling(i));
    }
  }