// File: RedBlackTreeTest.java

import redblacktree.*;

class RedBlackTreeTest {

	
	/**
	 * Test program for testing the ADT RedBlackTree.
	 */
	public static void main(String[] args) {

		// Create a random tree
		final int NUM_NODES = 20;
		final int MIN_KEY = -30;
		final int MAX_KEY = 40;

		RedBlackTree t = new RedBlackTree();
		int k;

		for (int i = 0; i < NUM_NODES; i++) {
			// Create a random key value
			k = (int)Math.round(MIN_KEY + (MAX_KEY - MIN_KEY) * Math.random());

			// Insert a new node with the selected key
			t.insert(new NodeKey(k));
		}

		if (t.nodeCount() != NUM_NODES)
			System.out.println("Wrong number of nodes.");

		if (!t.isRedBlackTree())
			System.out.println("t is not a black-red tree.");

		// Visual inspection of the tree
		t.printTree();
		
		System.exit(0);
	}	
}

