blob: 5d04000920e46ad91a27e878e9e3ee01e81b3e05 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package com.jantuomi.tunkki;
import com.jantuomi.tunkki.exception.TunkkiError;
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(Tunkki.getInstance().parseArguments(notAnArgument));
}
@Test
public void testParseArguments2() {
String[] fileTestArgument = {"-f", "test.file"};
assertTrue(Tunkki.getInstance().parseArguments(fileTestArgument));
}
@Test
public void testWholeProcedure() throws TunkkiError {
String input = "- + 2 5 1";
Tunkki.getInstance().run(input);
assertTrue(out.toString().contains("6"));
}
}
|