-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDaysOfMonthTest.java
More file actions
46 lines (45 loc) · 1.33 KB
/
Copy pathDaysOfMonthTest.java
File metadata and controls
46 lines (45 loc) · 1.33 KB
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
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.After;
import org.junit.Before;
public class DaysOfMonthTest {
private PrintStream _saved;
}
private ByteArrayOutputStream _actual;
private ByteArrayOutputStream _expected;
private PrintStream _out;
@Before
public void before() {
_saved = System.out;
_actual = new ByteArrayOutputStream();
_expected = new ByteArrayOutputStream();
System.setOut(new PrintStream(
new BufferedOutputStream(_actual)));
_out = new PrintStream(
new BufferedOutputStream(_expected));
}
@After
public void after() {
System.setOut(_saved);
}
@Test
public void wrong_month() {
_out.println("Usage: DaysOfMonth <year> <month>");
_out.flush();
String arg[] = new String[] {"2012", "13"};
DaysOfMonth.main(arg);
System.out.flush();
assertEquals(_expected.toString(), _actual.toString());
}
@Test
public void wrong_args() {
_out.println("Usage: DaysOfMonth <year> <month>");
_out.flush();
String arg[] = new String[] {"2012"};
DaysOfMonth.main(arg);
System.out.flush();
assertEquals(_expected.toString(), _actual.toString());
}