package binary_search_tree;

import java.util.NoSuchElementException;
import binary_search_tree.Bst;	// My implementation of Binary Search Tree in package binary_search_tree

/*
	Class to test class Bst. (Binary Search Tree)
*/

class TestBst{

			

	// Tests Insertion
	public static void testInsertion(){

		// Create a bst object
		Bst bst = new Bst();

		// Test inorder when tree is empty. Should throw exception
		try{
			bst.inOrder();
		}
		catch(NoSuchElementException e){
			System.out.println(e);
		}


		// Create array of integers to insert
		int[] values = {10, 7, 9, 8, 2, 15, 13, 17};

		// Insert values into bst
		for(int v: values){
			bst.insert(v);
		}

		// Print In Order traversal
		System.out.print("Inorder Traversal:\t ");
		bst.inOrder();

		System.out.println();
		System.out.println("Should be:\t\t 2 7 8 9 10 13 15 17");

	}



	public static void main(String args[]){

		// Test Insertion
		testInsertion();
	}

}

@@ -262,17 +262,32 @@
 nsertion
+ and traversals
 %0A
-
 %09public 
@@ -379,11 +379,13 @@
 est 
-ino
+Pre O
 rder
@@ -524,16 +524,176 @@
 ;%0A%09%09%7D%0A%0A%0A
+%09%09// Test Pre Order when tree is empty. Should throw exception%0A%09%09try%7B%0A%09%09%09bst.preOrder();%0A%09%09%7D%0A%09%09catch(NoSuchElementException e)%7B%0A%09%09%09System.out.println(e);%0A%09%09%7D%0A%0A%0A
 %09%09// Cre
@@ -770,16 +770,19 @@
 13, 17%7D;
+%0A%09%09
 %0A%0A%09%09// I
@@ -1026,20 +1026,204 @@
  17%22);%0A%0A
+%0A%09%09// Print Pre Order traversal%0A%09%09System.out.print(%22Pre order Traversal:%5Ct %22);%0A%09%09bst.preOrder();%0A%0A%09%09System.out.println();%0A%09%09System.out.println(%22Should be:%5Ct%5Ct 10 7 2 9 8 15 13 17%22);%0A%0A
 %09%7D%0A%0A
+%0A
 %0A%0A%09publi

Add tes case for pre order traversal