Tester.java
class Tester {
static boolean allTestsPassed=true;
static int numTestsFailed=0;
static void test(Object actual, Object expected) {
if ( actual != expected ) {
System.out.println("Test failed: expected \"" + expected + "\" but got \"" + actual + "\"");
allTestsPassed=false;
numTestsFailed++;
}
}
static void test(String actual, String expected) {
if ( actual != expected ) {
System.out.println("Test failed: expected \"" + expected + "\" but got \"" + actual + "\"");
allTestsPassed=false;
numTestsFailed++;
}
}
static void test(Integer actual, Integer expected) {
if ( !actual.equals(expected) ) {
System.out.println("Test failed: expected \"" + expected + "\" but got \"" + actual + "\"");
allTestsPassed=false;
numTestsFailed++;
}
}
static void test(boolean actual, boolean expected) {
if ( actual != expected ) {
System.out.println("Test failed: expected \"" + expected + "\" but got \"" + actual + "\"");
allTestsPassed=false;
numTestsFailed++;
}
}
static void printResults() {
if (allTestsPassed) System.out.println("All Tests Passed!");
else System.out.println(numTestsFailed + " tests failed.");
}
}
Generated by GNU enscript 1.6.3.