-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamplesTests.java
More file actions
90 lines (80 loc) · 3.38 KB
/
ExamplesTests.java
File metadata and controls
90 lines (80 loc) · 3.38 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
83
84
85
86
87
88
89
90
package cs3500.reversi;
import cs3500.reversi.model.Reversi;
import cs3500.reversi.model.CubicPosn;
import cs3500.reversi.model.DiskState;
import org.junit.Before;
import org.junit.Test;
/**
* Testing class for surface level clear testing of our Model, simple functionality.
*/
public class ExamplesTests {
Reversi game;
@Before
public void setup() {
game = new Reversi();
}
// Demonstrating starting a game with the correct initial layout
@Test
public void testStartGameWithInitialLayout() {
game.startGame(4);
assertEquals(DiskState.WHITE, game.getBoard().get(new CubicPosn(-1, 0)));
assertEquals(DiskState.WHITE, game.getBoard().get(new CubicPosn(1, -1)));
assertEquals(DiskState.WHITE, game.getBoard().get(new CubicPosn(0, 1)));
assertEquals(DiskState.BLACK, game.getBoard().get(new CubicPosn(1, 0)));
assertEquals(DiskState.BLACK, game.getBoard().get(new CubicPosn(0, -1)));
assertEquals(DiskState.BLACK, game.getBoard().get(new CubicPosn(-1, 1)));
}
// Demonstrating placing a black tile on the board and flipping the white tile
@Test
public void testPlaceBlackTileAndFlip() {
game.startGame(4);
game.placeTile(new CubicPosn(2, -1), DiskState.BLACK);
assertEquals(DiskState.BLACK, game.getBoard().get(new CubicPosn(2, -1)));
assertEquals(DiskState.BLACK, game.getBoard().get(new CubicPosn(1, 0)));
}
// Demonstrating placing a white tile on the board and flipping the black tile
@Test
public void testPlaceWhiteTileAndFlip() {
game.startGame(4);
game.placeTile(new CubicPosn(-1, 2), DiskState.WHITE);
assertEquals(DiskState.WHITE, game.getBoard().get(new CubicPosn(-1, 2)));
assertEquals(DiskState.WHITE, game.getBoard().get(new CubicPosn(0, 1)));
}
// Demonstrating placing a black tile in a position which causes two directions to flip
@Test
public void testPlaceWithDoubleFlipDifferentDirection() {
game.startGame(4);
game.placeTile(new CubicPosn(2, -1), DiskState.BLACK);
game.placeTile(new CubicPosn(1, -2), DiskState.WHITE);
game.placeTile(new CubicPosn(-1, -1), DiskState.BLACK);
assertEquals(DiskState.BLACK, game.getBoard().get(new CubicPosn(-1, 0)));
assertEquals(DiskState.BLACK, game.getBoard().get(new CubicPosn(0, -1)));
}
// Demonstrating placing a tiles in a position which causes flip in tiles in the same direction
@Test
public void testPlaceWithDoubleFlipSameDirection() {
game.startGame(4);
game.placeTile(new CubicPosn(2, -1), DiskState.WHITE);
game.placeTile(new CubicPosn(3, -1), DiskState.BLACK);
assertEquals(DiskState.BLACK, game.getBoard().get(new CubicPosn(1, -1)));
assertEquals(DiskState.BLACK, game.getBoard().get(new CubicPosn(2, -1)));
}
// tests that a game is not over
@Test
public void testGameNotOver() {
game.startGame(2);
assertFalse(game.isGameOver());
}
// tests that a game is over
@Test
public void testGameOver() {
game.startGame(2);
game.placeTile(new CubicPosn(1, -2), DiskState.BLACK);
game.placeTile(new CubicPosn(2, -1), DiskState.WHITE);
game.placeTile(new CubicPosn(1, 1), DiskState.BLACK);
game.placeTile(new CubicPosn(-1, 2), DiskState.WHITE);
game.placeTile(new CubicPosn(-2, 1), DiskState.BLACK);
game.placeTile(new CubicPosn(-1, -1), DiskState.WHITE);
assertTrue(game.isGameOver());
}
}