-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimTest.java
More file actions
executable file
·82 lines (71 loc) · 1.8 KB
/
Copy pathSimTest.java
File metadata and controls
executable file
·82 lines (71 loc) · 1.8 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package edu.brandeis.cs12b.pa4.tests;
import static org.junit.Assert.*;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import edu.brandeis.cs12b.pa4.Car;
import edu.brandeis.cs12b.pa4.Simulator;
import edu.brandeis.cs12b.pa4.provided.City;
import edu.brandeis.cs12b.pa4.provided.Direction;
import edu.brandeis.cs12b.pa4.provided.Point;
public class SimTest {
private PrintStream sysOut;
private ByteArrayOutputStream outContent;
private static final String newLine = System.getProperty("line.separator");
private City straightLineSnowed;
private City straightLineCleared;
private City elbowSnowed;
@Before
public void setUp() throws Exception {
sysOut = System.out;
outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
//HERE ARE SOME STOCK CITIES FOR YOU TO USE ON YOUR TESTS
straightLineSnowed = new City(new int[][]{
{0,0,0},
{0,1,0},
{0,1,0},
{0,1,0},
{0,1,0},
{0,1,0},
{0,1,0},
{0,0,0},
});
straightLineCleared = new City(new int[][]{
{0,0,0},
{0,2,0},
{0,2,0},
{0,2,0},
{0,2,0},
{0,2,0},
{0,2,0},
{0,0,0},
});
elbowSnowed = new City(new int[][]{
{0,0,0,0,0,0},
{0,0,1,0,0,0},
{0,0,1,0,0,0},
{0,0,1,0,0,0},
{0,0,1,0,0,0},
{0,0,1,0,0,0},
{0,0,1,1,0,0},
{0,0,0,0,0,0},
});
}
@After
public void tearDown() throws Exception {
System.setOut(sysOut);
}
@Test
public void testClearedCity() {
Simulator sim = new Simulator(straightLineCleared);
assertTrue(sim.isClear());
}
@Test
public void testSnowedCity() {
Simulator sim = new Simulator(straightLineSnowed);
assertFalse(sim.isClear());
}
}