/**
 * Unit test cases for the implementation of a Binary Search Tree.
 *
 * @author  __your_name___
 */

import static org.junit.Assert.*;

import java.util.NoSuchElementException;

import org.junit.Test;

public class BSTreeTest
{
	/**
	 * the tree to use for testing
	 */
	private BSTree<Integer> tree;

	// returns a tree loaded with the given items
	static BSTree<Integer> load(Integer... items)
	{
		IntComparator compare = new IntComparator();
		BSTree<Integer> tree = new BSTree<Integer>(compare);
		for (Integer value : items) {
			tree.addLoop(value);
		}
		return tree;
	}

	@Test
	public void test_addLoop()
	{
		// testing empty
		tree = load( _nothing_ );
		tree.addLoop( _a_number_ );
		assertEquals( tree.toString(), "[?]" );

		// testing single
		tree = load( _a_number_ );
		tree.addLoop( _a_number_ );
		assertEquals( tree.toString(), "[? ?]" );

		*** one test case for single is not enough ***

		// testing multi
		tree = load( s,e,v,e,r,a,l,n,u,m,b,e,r,s );
		tree.addLoop( _a_number_ );
		assertEquals( tree.toString(), "[? ? ? ... ?]" );

		*** one test case for multi is not enough ***
	}

	@Test
	public void test_maxValueLoop()
	{
		// testing empty
		tree = load( _nothing_ );
		assertThrows( tree.maxValueLoop() );
		assertEquals( tree.toString(), "[?]" );

		// testing single
		tree = load( _a_number_ );
		assertTrue( tree.maxValueLoop() == ? );
		assertEquals( tree.toString(), "[?]" );

		// testing multi
		tree = load( s,e,v,e,r,a,l,n,u,m,b,e,r,s );
		assertTrue( tree.maxValueLoop() ==  ? );
		assertEquals( tree.toString(), "[? ? ? ... ?]" );
	}
}