import java.io.*;

/** A simple test driver designed for debugging a program or its testcases.  
 *  
 *  BasicTestDriver needs only BasicLogger and TestCases to run, making it
 *  a small and simple test driver.  Allthough it can't catch infinite loops,
 *  it's intended to help instructors write test cases and students debug
 *  their assignments.
 */
public class BasicTestDriver {
    public static void main(String args[]) {
        boolean stopFirstError = false;
        //boolean stopFirstError = true;

        //The BasicLogger just prints results to the screen as they
        //happen.  It's simple and chatty.
        Logger logger = new BasicLogger();

        //The ReportLogger is the logger used for the actual
        //automarking.  It tries to be as concise as possible, but
        //it doesn't produce anything until the end--so it's not
        //the ideal debugging logger.
        //Logger logger = new ReportLogger(TestCases.TOTAL_TESTS);
        TestCases tc = new TestCases(logger);
        boolean result;
        int numberPassed = 0;


        for (int i = 0; i != TestCases.TOTAL_TESTS; i++) {
            result = true;
            try {
                result = tc.runTest(i);
                logger.logResult(i, result);
                if (result) {
                    numberPassed++;
                } else if (stopFirstError) {
                }
            } catch (java.lang.Throwable e) {
                result = false;
                logger.logResult(i, e);
            }
            if (result == false && stopFirstError) {
                logger.printDebug(i, "info", "Found an error, stopping");
                break;
            }
        }

        System.out.println(numberPassed + " of the " + TestCases.TOTAL_TESTS + " test cases succeeded.");

        return;
   }
}


