import datastructures.SkipList;
import tools.Utilities;

public class SkipListTest {
    static SkipList sList;
    public static void main(String[] args) throws Exception {
        for (int i = 0; i < 5; i ++)
            testSimpleUniqueInsertion(50 + ((int) (Math.random() * 50)));
    }

    private static void testSimpleUniqueInsertion(int length) throws Exception {
        System.out.printf("\tTestSimpleUniqueInsertion (n = %d)\n", length);
        SkipList list = new SkipList();
        boolean[] visited = new boolean[1024];
        for (int i = 0; i < length; i ++) {
            // Find a unique element to insert.
            int value;
            do {
                value = (int) (Math.random() * 100) + 1;
            } while (visited[value]);
            visited[value] = true;

            list.add(value);
        }

        int[] array = list.toArray();

        for (int i = 0; i < array.length - 1; i ++) {
            if (array[i] >= array[i + 1]) throw new Exception(String.format("Invalid sorted order: %s", Utilities.toString(array)));
        }
    }
}
@@ -278,22 +278,48 @@
  50)));%0A
+        testUniqueFind();%0A
     %7D%0A
-
 %0A    pri
@@ -568,34 +568,851 @@
     
-for (int i = 0; i %3C length
+addToList(list, length, visited);%0A%0A        int%5B%5D array = list.toArray();%0A%0A        for (int i = 0; i %3C array.length - 1; i ++) %7B%0A            if (array%5Bi%5D %3E= array%5Bi + 1%5D) throw new Exception(String.format(%22Invalid sorted order: %25s%22, Utilities.toString(array)));%0A        %7D%0A    %7D%0A%0A    private static void testUniqueFind() throws Exception %7B%0A        System.out.println(%22%5CtTestUniqueFind%22);%0A        SkipList list = new SkipList();%0A        boolean%5B%5D visited = new boolean%5B4096%5D;%0A        addToList(list, visited.length / 2, visited);%0A%0A        for (int i = 0; i %3C visited.length; i ++) %7B%0A            if (visited%5Bi%5D && !list.find(i)) throw new Exception(%22Element not found in SkipList%22);%0A        %7D%0A    %7D%0A%0A    private static void addToList(SkipList list, int numOfElements, boolean%5B%5D visited) throws Exception %7B%0A        for (int i = 0; i %3C numOfElements
 ; i 
@@ -1556,11 +1556,21 @@
 ) * 
-100
+numOfElements
 ) + 
@@ -1690,244 +1690,8 @@
  %7D%0A%0A
-        int%5B%5D array = list.toArray();%0A%0A        for (int i = 0; i %3C array.length - 1; i ++) %7B%0A            if (array%5Bi%5D %3E= array%5Bi + 1%5D) throw new Exception(String.format(%22Invalid sorted order: %25s%22, Utilities.toString(array)));%0A        %7D%0A
     

Add unique find test