Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
h908714124 committed Sep 28, 2024
1 parent 1dadc6b commit 0237f13
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/main/java/com/bernd/model/GameBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public final class GameBuilder {
private int state;
private int[][] board;
private int[] forbidden;
private long updated = System.currentTimeMillis();

private GameBuilder(Game game) {
this.game = game;
Expand All @@ -30,6 +31,11 @@ public GameBuilder withForbidden(int x, int y) {
return withForbidden(new int[]{x, y});
}

GameBuilder withUpdated(long updated) {
this.updated = updated;
return this;
}

static GameBuilder builder(Game game) {
GameBuilder builder = new GameBuilder(game);
builder.state = game.state();
Expand All @@ -47,7 +53,7 @@ public Game build() {
board,
game.dim(),
game.timesetting(),
System.currentTimeMillis(),
updated,
game.handicap(),
forbidden,
game.moves()
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/com/bernd/model/GameBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ void unchanged() {
"123",
"bernd",
"heike",
true,
1,
createEmptyBoard(9),
9,
2,
10,
1727532679000L,
0,
new int[]{-1, -1},
MoveList.create(2));
Game game2 = GameBuilder.builder(game).build();
Game game2 = GameBuilder.builder(game).withUpdated(game.updated()).build();
assertEquals(game, game2);
}
}
13 changes: 12 additions & 1 deletion src/test/java/com/bernd/util/SgfCreatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@ void testCreate() {
MoveList moveList = MoveList.create(20);
moveList.add(new Move(Board.B, 0, null, 3, 4));
moveList.add(new Move(Board.W, 0, null, 6, 4));
Game game = new Game("1234", "B", "W", false, new int[9][], 9, 0, 0, new int[]{-1, -1}, moveList);
Game game = new Game(
"1234",
"B",
"W",
1,
new int[9][],
9,
10,
1727532679000L,
0,
new int[]{-1, -1},
moveList);
String sgf = SgfCreator.createSgf(game, LocalDate.of(2024, Month.AUGUST, 30));
assertEquals("(;FF[4]CA[UTF-8]GM[1]DT[2024-08-30]GN[1234]PB[B]PW[W]RE[?]SZ[9];B[de];W[ge])",
sgf.replace("\n", ""));
Expand Down

0 comments on commit 0237f13

Please sign in to comment.