Created
March 11, 2012 09:53
-
-
Save jeffyu/2015811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package VC; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.io.PrintStream; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class TestRunner { | |
private static List<String> testcases = new ArrayList<String>(); | |
static { | |
testcases.add("VC/Scanner/comment1.vc"); | |
testcases.add("VC/Scanner/comment2.vc"); | |
testcases.add("VC/Scanner/comment3.vc"); | |
testcases.add("VC/Scanner/comment4.vc"); | |
testcases.add("VC/Scanner/error1.vc"); | |
testcases.add("VC/Scanner/error2.vc"); | |
testcases.add("VC/Scanner/error3.vc"); | |
testcases.add("VC/Scanner/error4.vc"); | |
testcases.add("VC/Scanner/escape.vc"); | |
testcases.add("VC/Scanner/fib.vc"); | |
testcases.add("VC/Scanner/gcd.vc"); | |
testcases.add("VC/Scanner/longestmatch.vc"); | |
testcases.add("VC/Scanner/string.vc"); | |
testcases.add("VC/Scanner/tab.vc"); | |
testcases.add("VC/Scanner/tokens.vc"); | |
} | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) throws Exception { | |
for (String testcase : testcases) { | |
String base = testcase.substring(0, testcase.length() - 2); | |
String solFile = base + "sol"; | |
String resultFile = base + "output"; | |
System.setOut(new PrintStream(new File(resultFile))); | |
String[] arg = new String[1]; | |
arg[0] = testcase; | |
vc.main(arg); | |
byte[] r = getFileContent(resultFile); | |
String output = new String(r); | |
byte[] b = getFileContent(solFile); | |
String solString = new String(b); | |
if (!output.equals(solString)) { | |
System.err.println("Test Case [" + testcase + "] failed."); | |
} | |
} | |
} | |
private static byte[] getFileContent(String file) throws FileNotFoundException, IOException { | |
FileInputStream fis = new FileInputStream(file); | |
byte[] b = new byte[fis.available()]; | |
try { | |
fis.read(b); | |
} finally { | |
fis.close(); | |
} | |
return b; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment