-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoardTest.java
55 lines (42 loc) · 1.49 KB
/
BoardTest.java
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
import junit.framework.TestCase;
public class BoardTest extends TestCase {
Board b;
Piece pyr1, pyr2, pyr3, pyr4, s, sRotated;
// This shows how to build things in setUp() to re-use
// across tests.
// In this case, setUp() makes shapes,
// and also a 3X6 board, with pyr placed at the bottom,
// ready to be used by tests.
protected void setUp() throws Exception {
b = new Board(3, 6);
pyr1 = new Piece(Piece.PYRAMID_STR);
pyr2 = pyr1.computeNextRotation();
pyr3 = pyr2.computeNextRotation();
pyr4 = pyr3.computeNextRotation();
s = new Piece(Piece.S1_STR);
sRotated = s.computeNextRotation();
b.place(pyr1, 0, 0);
}
// Check the basic width/height/max after the one placement
public void testSample1() {
assertEquals(1, b.getColumnHeight(0));
assertEquals(2, b.getColumnHeight(1));
assertEquals(2, b.getMaxHeight());
assertEquals(3, b.getRowWidth(0));
assertEquals(1, b.getRowWidth(1));
assertEquals(0, b.getRowWidth(2));
}
// Place sRotated into the board, then check some measures
public void testSample2() {
b.commit();
int result = b.place(sRotated, 1, 1);
assertEquals(Board.PLACE_OK, result);
assertEquals(1, b.getColumnHeight(0));
assertEquals(4, b.getColumnHeight(1));
assertEquals(3, b.getColumnHeight(2));
assertEquals(4, b.getMaxHeight());
}
// Makre more tests, by putting together longer series of
// place, clearRows, undo, place ... checking a few col/row/max
// numbers that the board looks right after the operations.
}