
// This is the tester for student programs.
// The idea is to run all the test files, create the HTML, etc.
// Dan Grossman 17 April 1998

// This is pretty quick and dirty

import java.io.*;

public class TestAll {

	// Change directory to "" for running with students stuff ??
	private final String [] classes =
		{ "One",
		  "Two",
		  "Three",
		  "Four",
		  "Five",
		  "Six",
		  "Seven",
		  "Eight",
		  "Nine",
		  "Ten",
		  "Eleven",
		  "Twelve",
		  "Thirteen",
		  "Fourteen",
		  "Fifteen",
		  "Sixteen"
		 };
		 
	private PrintWriter pw;
	private int numRight;

	private void testOneFile (String s) {
	
		pw.print("Start " + s);
		System.out.println("Starting " + s);
		
		try {
			Documenter m = new Documenter();
			m.documentClass(s);
		} catch (Exception e) {
			numRight--;
			pw.print("\t***Exception***\t");
			pw.println(e);
			return;
		}
		
		pw.println("\tfinish " + s);
	}
	
	public void testAll() throws IOException {
		numRight = classes.length; 
		pw = new PrintWriter(new FileOutputStream("testSuiteOutput.txt"));
		for (int i = 0; i < classes.length; i++)
			testOneFile(classes[i]);
		if (numRight == 0) {
			pw.println("\nNONE RIGHT. ATTEMPTING .java suffix extension!\n");
			for (int i = 0; i < classes.length; i++)
				testOneFile(classes[i]+".java");
		}
		pw.close();			
	}
	
	public static void main (String [] args) throws IOException {
		TestAll t = new TestAll();
		t.testAll();
		System.out.println("Testing completed, press return at will.");
		System.in.read();
	}
}