m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl/edu
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-11-11 13:21:30 +0100
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-11-11 13:21:30 +0100
commitfba2e1f41625a998624c6918eaf034cf3e9bd71a (patch)
tree1df8815b9a65d8f92ff72de6f5a918a796c9b897 /src/test/java/pl/edu
parent900fb0aee0b68cbb88f578f20019738b4416f436 (diff)
Add interpreter tests
Diffstat (limited to 'src/test/java/pl/edu')
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java126
1 files changed, 126 insertions, 0 deletions
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java b/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java
new file mode 100644
index 0000000..54312b8
--- /dev/null
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java
@@ -0,0 +1,126 @@
+package pl.edu.mimuw.cloudatlas.interpreter;
+
+import java.io.PrintStream;
+import java.io.FileInputStream;
+import java.io.File;
+import java.io.ByteArrayOutputStream;
+import java.net.URL;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+public class InterpreterTests {
+ @Test
+ public void fileTest1() throws Exception {
+ runFileTest(1);
+ }
+
+ @Test
+ public void fileTest2() throws Exception {
+ runFileTest(2);
+ }
+
+ @Test
+ public void fileTest3() throws Exception {
+ runFileTest(3);
+ }
+
+ @Test
+ public void fileTest4() throws Exception {
+ runFileTest(4);
+ }
+
+ @Test
+ public void fileTest5() throws Exception {
+ runFileTest(5);
+ }
+
+ @Test
+ public void fileTest6() throws Exception {
+ runFileTest(6);
+ }
+
+ @Test
+ public void fileTest7() throws Exception {
+ runFileTest(7);
+ }
+
+ @Test
+ public void fileTest8() throws Exception {
+ runFileTest(8);
+ }
+
+ @Test
+ public void fileTest9() throws Exception {
+ runFileTest(9);
+ }
+
+ @Test
+ public void fileTest10() throws Exception {
+ runFileTest(10);
+ }
+
+ @Test
+ public void fileTest11() throws Exception {
+ runFileTest(11);
+ }
+
+ @Test
+ public void fileTest12() throws Exception {
+ runFileTest(12);
+ }
+
+ @Test
+ public void fileTest13() throws Exception {
+ runFileTest(13);
+ }
+
+ @Test
+ public void fileTest14() throws Exception {
+ runFileTest(14);
+ }
+
+ @Test
+ public void fileTest15() throws Exception {
+ runFileTest(15);
+ }
+
+ @Test
+ public void fileTest16() throws Exception {
+ runFileTest(16);
+ }
+
+ @Test
+ public void fileTest17() throws Exception {
+ runFileTest(17);
+ }
+
+ @Test
+ public void fileTest18() throws Exception {
+ runFileTest(18);
+ }
+
+ @Test
+ public void fileTest19() throws Exception {
+ runFileTest(19);
+ }
+
+ private void runFileTest(int i) throws Exception {
+ URL test = InterpreterTests.class.getResource(i + ".in");
+ URL testOut = InterpreterTests.class.getResource(i + ".out");
+
+ FileInputStream in = new FileInputStream(test.getFile());
+ ByteArrayOutputStream outByteArray = new ByteArrayOutputStream();
+ PrintStream outPrint = new PrintStream(outByteArray);
+ Main.runTest(in, outPrint);
+ String actual = outByteArray.toString();
+
+ File expectedFile = new File(testOut.getFile());
+ FileInputStream expectedIn = new FileInputStream(expectedFile);
+ byte[] buffer = new byte[(int)expectedFile.length()];
+ expectedIn.read(buffer);
+ String expected = new String(buffer, "UTF-8");
+
+ assertEquals(expected, actual);
+ }
+}