예제 #1
0
 // ------------------------------------------------------------
 @Test
 public void testRotation() {
   int nbOfRotations = 10000;
   for (int i = 0; i < nbOfRotations; i++) {
     BTree<Integer> t;
     int size = rnd.nextInt(10) + 6;
     do t = rndTree(size);
     while (itrWithRights.isEmpty());
     int ri = rnd.nextInt(itrWithRights.size());
     BTreeItr<Integer> ti = ((itrWithRights.get(ri)));
     String s0 = t.toReadableString();
     if (i == 0) System.out.println("original" + s0);
     if (i == 0) System.out.println("rotated left on " + ti.consult());
     ti.rotateLeft();
     String s1 = t.toReadableString();
     if (i == 0) System.out.println(s1);
     ti.rotateRight();
     String s2 = t.toReadableString();
     if (i == 0) System.out.println("then right again" + s2);
     assertTrue(s0.equals(s2));
     assertFalse(s0.equals(s1));
   }
 }