aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jantuomi/borker/MainTest.java
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2016-06-28 21:09:43 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2016-07-26 19:47:12 +0300
commit8f84c00978dc05007873a9fe1de6a18511dc3cf8 (patch)
tree39fead540e22addee40b95b68db08cbea620745b /src/test/com/jantuomi/borker/MainTest.java
parent48dcd488054024d98fe1e659a4029630130d1d35 (diff)
Restructure project for use with maven
Diffstat (limited to 'src/test/com/jantuomi/borker/MainTest.java')
-rw-r--r--src/test/com/jantuomi/borker/MainTest.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/test/com/jantuomi/borker/MainTest.java b/src/test/com/jantuomi/borker/MainTest.java
new file mode 100644
index 0000000..e0342a4
--- /dev/null
+++ b/src/test/com/jantuomi/borker/MainTest.java
@@ -0,0 +1,52 @@
+package com.jantuomi.borker;
+
+import com.jantuomi.borker.exception.InterpreterException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Created by jan on 10.6.2016.
+ */
+public class MainTest {
+
+ private final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ private PrintStream originalOut;
+
+ @Before
+ public void setupStreams() {
+ originalOut = System.out;
+ System.setOut(new PrintStream(out));
+ }
+
+ @After
+ public void cleanStreams() {
+ System.setOut(originalOut);
+ }
+
+ @Test
+ public void testParseArguments1() {
+ String[] notAnArgument = {"--not-an-argument"};
+ assertFalse(Main.parseArguments(notAnArgument));
+ }
+
+ @Test
+ public void testParseArguments2() {
+ String[] fileTestArgument = {"-f", "test.file"};
+ assertTrue(Main.parseArguments(fileTestArgument));
+ }
+
+ @Test
+ public void testWholeProcedure() throws InterpreterException {
+ String input = "- + 2 5 1";
+
+ Main.run(input);
+ assertTrue(out.toString().contains("6"));
+ }
+} \ No newline at end of file