/* <hr/><h2>Simple test harness for InsertSort</h2>
   <!--(c) Harold Thimbleby, 2002-->
 */
 
// <pre>
import java.io.*;

class Test
{	public static void main(String args[])
	{	System.out.println("// <save file='output.html'><pre><!-- for whole file translation to XHTML-->");
		for( int type = 1; type <= 2; type++ )
		{	int v[] = { 2, 9, 3, 4, 1, 5, 8, 1, 4, 8, 7, 6 };
			Integer test[] = IntegerVector(v);
			System.out.println("// <save file='sortoutput.tex'>\n"
				+(type==InsertSort.UNSTABLE? "Unstable sort": "Stable sort")
				+"\n    Before sorting "+tostring(test));
			InsertSort.sort((Comparable[]) test, type);
			System.out.println("    After sorting  "+tostring(test)+"\n// </save>");
		}
		System.out.println("// </pre></save>");
	}
	
	static Integer[] IntegerVector(int [] t)
	{	Integer i[] = new Integer[t.length];
		for( int j = 0; j < t.length; j++ )
			i[j] = new Integer(t[j]);
		return i;
	}
	
	static String tostring(Integer a[])
	{	String s = "";
		for( int i = 0; i < a.length; s += a[i++])
			if( i > 0 ) s += ", ";
		return "["+s+"]";
	}
} // </pre>

