示例#1
0
  public void testClone() {
    for (int s = 0; s < 2; s++) {
      IntTree it = initIntTree(s);
      IntTree it2 = new IntTree();
      it2.clone(it);

      assertEquals(it.size(), it2.size());
      for (int i = 0; i < it.size(); i++) {
        assertEquals(
            ((Integer) it.get(ranNums[i])).intValue(), ((Integer) it2.get(ranNums[i])).intValue());
      }
      for (int i = 0; i < it.size(); i++) {
        assertEquals(it.getKeyIdx(i), it2.getKeyIdx(i));
      }
      for (int i = 0; i < it.size(); i++) {
        assertEquals(it.getValueIdx(i), it2.getValueIdx(i));
      }
    }
  }
示例#2
0
 public void testGetKeyIdx() {
   for (int s = 0; s < 1; s++) { // Don't use random ordering as may
     // contain duplicates
     IntTree it = initIntTree(s);
     int[] sortRanNums = ranNums.clone();
     Arrays.sort(sortRanNums);
     for (int i = 0; i < sortRanNums.length; i++) {
       assertEquals("Key of idx " + i + " was not as expected", sortRanNums[i], it.getKeyIdx(i));
     }
   }
 }