Exemple #1
0
 public void testGet() {
   for (int s = 0; s < 2; s++) {
     IntTree it = initIntTree(s);
     for (int i = 0; i < ranNums.length; i++) {
       assertEquals(ranNums[i], ((Integer) it.get(ranNums[i])).intValue());
     }
   }
 }
Exemple #2
0
 public void testRemove() {
   for (int s = 0; s < 1; s++) { // Don't use random ordering as may
     // contain duplicates
     IntTree it = initIntTree(s);
     Random rr = new Random();
     int noRemov = 0;
     for (int i = 0; i < ranNums.length; i++) {
       if (rr.nextInt(100) < 20) {
         assertEquals(ranNums[i], ((Integer) it.get(ranNums[i])).intValue());
         it.remove(ranNums[i]);
         noRemov++;
         assertEquals(ranNums.length - noRemov, it.size());
         assertEquals(null, it.get(ranNums[i]));
       }
     }
   }
 }
Exemple #3
0
 public void testRemoveAll() {
   for (int s = 0; s < 2; s++) {
     IntTree it = initIntTree(s);
     it.removeAll();
     assertEquals("Test number of entries before deleting:", 0, it.size());
     for (int i = 0; i < ranNums.length; i++) {
       assertEquals("Test elements are deleted:", null, it.get(ranNums[i]));
     }
   }
 }
Exemple #4
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));
      }
    }
  }