From adf768f1c0635954b5278a46c6eab7ec9deb357c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 3 Jul 2020 15:57:21 +0200 Subject: =?UTF-8?q?Tests=20:=20add=20testCenter(=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/src/ch/asynk/gdx/boardgame/test/Tests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/src/ch/asynk/gdx/boardgame/test/Tests.java b/test/src/ch/asynk/gdx/boardgame/test/Tests.java index 034bf65..eff7afa 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/Tests.java +++ b/test/src/ch/asynk/gdx/boardgame/test/Tests.java @@ -29,9 +29,13 @@ public class Tests private void runHexVertical() { + System.err.println(" * Vertical HexBoard"); board = BoardFactory.getBoard(10, 9, BoardFactory.BoardType.HEX, 110, 50, 103, BoardFactory.BoardOrientation.VERTICAL, this::getTile); tileStorage = new ArrayTileStorage(board.size()); check((board.size() == 86), "Vertical ", "size", board.size()); + testCenter(5, 3, 812, 653); + testCenter(5, 2, 907, 488); + testCenter(6, 3, 1002, 653); testTouch(899, 602, 5, 3, 812, 653, 32); testTouch(906, 593, 5, 2, 907, 488, 23); testTouch(916, 601, 6, 3, 1002, 653, 33); @@ -39,14 +43,26 @@ public class Tests private void runHexHorizontal() { + System.err.println(" * Horizontal HexBoard"); board = BoardFactory.getBoard(9, 10, BoardFactory.BoardType.HEX, 110, 103, 50, BoardFactory.BoardOrientation.HORIZONTAL, this::getTile); tileStorage = new ArrayTileStorage(board.size()); check((board.size() == 86), "Horizontal ", "size", board.size()); + testCenter(3, 7, 653, 1193); + testCenter(3, 6, 653, 1002); + testCenter(4, 7, 818, 1097); testTouch(705, 1103, 3, 7, 653, 1193, 34); testTouch(707, 1092, 3, 6, 653, 1002, 33); testTouch(715, 1096, 4, 7, 818, 1097, 43); } + private void testCenter(int x, int y, int cx, int cy) + { + String title = String.format("[%d;%d] -> (%d;%d) ", x, y, cx, cy); + board.centerOf(x, y, v); + check(((int)v.x == cx), title, "cx", (int)v.x); + check(((int)v.y == cy), title, "cy", (int)v.y); + } + private void testTouch(int tx, int ty, int x, int y, int cx, int cy, int g) { String title = String.format("[%d;%d] -> [%d;%d] (%d;%d) %d : ", tx, ty, x, y, cx, cy, g); -- cgit v1.1-2-g2b99