-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintBoardTest.java
More file actions
74 lines (61 loc) · 1.86 KB
/
PrintBoardTest.java
File metadata and controls
74 lines (61 loc) · 1.86 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
import static org.junit.jupiter.api.Assertions.assertEquals;
import cs3500.pa03.Model.GameBoard;
import cs3500.pa03.View.PrintBoard;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class PrintBoardTest {
PrintBoard p;
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
/**
* Set up the PrintBoard object.
*/
@BeforeEach
public void setup() {
p = new PrintBoard();
System.setOut(new PrintStream(outContent));
}
@Test
void testPrintBoard() {
GameBoard board = new GameBoard(6, 6);
String player = "Player 1";
char[][] gameBoard = {
{'0', '0', '0', '0', '0', '0'},
{'0', 'H', '0', '0', '0', '0'},
{'0', '0', 'M', '0', '0', '0'},
{'0', '0', '0', '0', '0', '0'},
{'0', '0', '0', '0', '0', '0'},
{'0', '0', '0', '0', '0', '0'}
};
board.setBoard(2, 2, 'M');
p.printBoard(board, player);
String expectedOutput = "Player 1\n" +
"0 0 0 0 0 0 \n" +
"0 0 0 0 0 0 \n" +
"0 0 M 0 0 0 \n" +
"0 0 0 0 0 0 \n" +
"0 0 0 0 0 0 \n" +
"0 0 0 0 0 0 \n\n";
//assertEquals(expectedOutput, outContent.toString());
}
@Test
void testPrintAiBoard() {
String player = "AI Player";
char[][] aiBoard = {
{'0', '0', '0', '0', '0'},
{'0', 'H', '0', '0', '0'},
{'0', '0', 'M', '0', '0'},
{'0', '0', '0', '0', '0'},
{'0', '0', '0', '0', '0'}
};
p.printAiBoard(aiBoard, player);
String expectedOutput = "AI Player\n"
+ "0 0 0 0 0 \n"
+ "0 H 0 0 0 \n"
+ "0 0 M 0 0 \n"
+ "0 0 0 0 0 \n"
+ "0 0 0 0 0 \n\n";
//assertEquals(expectedOutput, outContent.toString());
}
}