From b1a8ad8fb9732545bd917082cf76be96a5475b1f Mon Sep 17 00:00:00 2001 From: Fulminazzo Date: Wed, 17 Apr 2024 16:43:34 +0200 Subject: [PATCH] Added rows and columns tests --- .../java/it/angrybear/yagl/guis/GUITest.java | 86 ++++++++++--------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/gui/base/src/test/java/it/angrybear/yagl/guis/GUITest.java b/gui/base/src/test/java/it/angrybear/yagl/guis/GUITest.java index ee834cc5..206ceabc 100644 --- a/gui/base/src/test/java/it/angrybear/yagl/guis/GUITest.java +++ b/gui/base/src/test/java/it/angrybear/yagl/guis/GUITest.java @@ -24,34 +24,34 @@ class GUITest { private static Object[][] expectedCorners() { return new Object[][]{ - new Object[]{9, 0, 4, 8, 0, 4, 8, 0, 4, 8}, - new Object[]{18, 0, 4, 8, 0, 4, 8, 9, 13, 17}, - new Object[]{27, 0, 4, 8, 9, 13, 17, 18, 22, 26}, - new Object[]{36, 0, 4, 8, 9, 13, 17, 27, 31, 35}, - new Object[]{45, 0, 4, 8, 18, 22, 26, 36, 40, 44}, - new Object[]{54, 0, 4, 8, 18, 22, 26, 45, 49, 53}, - new Object[]{GUIType.CHEST, 0, 4, 8, 9, 13, 17, 18, 22, 26}, - new Object[]{GUIType.DISPENSER, 0, 1, 2, 3, 4, 5, 6, 7, 8}, - new Object[]{GUIType.DROPPER, 0, 1, 2, 3, 4, 5, 6, 7, 8}, - new Object[]{GUIType.FURNACE, 0, 1, 2, 0, 1, 2, 0, 1, 2}, - new Object[]{GUIType.WORKBENCH, 0, 1, 2, 3, 4, 5, 6, 7, 8}, - new Object[]{GUIType.ENCHANTING, 0, 1, 1, 0, 1, 1, 0, 1, 1}, - new Object[]{GUIType.BREWING, 0, 1, 1, 2, 3, 4, 2, 3, 4}, - new Object[]{GUIType.PLAYER, 0, 4, 8, 9, 13, 17, 27, 31, 35}, - new Object[]{GUIType.ENDER_CHEST, 0, 4, 8, 9, 13, 17, 18, 22, 26}, - new Object[]{GUIType.ANVIL, 0, 1, 2, 0, 1, 2, 0, 1, 2}, - new Object[]{GUIType.SMITHING, 0, 1, 2, 0, 1, 2, 0, 1, 2}, - new Object[]{GUIType.BEACON, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - new Object[]{GUIType.HOPPER, 0, 2, 4, 0, 2, 4, 0, 2, 4}, - new Object[]{GUIType.SHULKER_BOX, 0, 4, 8, 9, 13, 17, 18, 22, 26}, - new Object[]{GUIType.BARREL, 0, 4, 8, 9, 13, 17, 18, 22, 26}, - new Object[]{GUIType.BLAST_FURNACE, 0, 1, 2, 0, 1, 2, 0, 1, 2}, - new Object[]{GUIType.LECTERN, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - new Object[]{GUIType.SMOKER, 0, 1, 2, 0, 1, 2, 0, 1, 2}, - new Object[]{GUIType.LOOM, 0, 1, 1, 0, 1, 3, 2, 2, 2}, - new Object[]{GUIType.CARTOGRAPHY, 0, 1, 2, 0, 1, 2, 0, 1, 2}, - new Object[]{GUIType.GRINDSTONE, 0, 1, 2, 0, 1, 2, 0, 1, 2}, - new Object[]{GUIType.STONECUTTER, 0, 1, 1, 0, 1, 1, 0, 1, 1}, + new Object[]{9, 0, 4, 8, 0, 4, 8, 0, 4, 8, 1, 9}, + new Object[]{18, 0, 4, 8, 0, 4, 8, 9, 13, 17, 2, 9}, + new Object[]{27, 0, 4, 8, 9, 13, 17, 18, 22, 26, 3, 9}, + new Object[]{36, 0, 4, 8, 9, 13, 17, 27, 31, 35, 4, 9}, + new Object[]{45, 0, 4, 8, 18, 22, 26, 36, 40, 44, 5, 9}, + new Object[]{54, 0, 4, 8, 18, 22, 26, 45, 49, 53, 6, 9}, + new Object[]{GUIType.CHEST, 0, 4, 8, 9, 13, 17, 18, 22, 26, 3, 9}, + new Object[]{GUIType.DISPENSER, 0, 1, 2, 3, 4, 5, 6, 7, 8, 3, 3}, + new Object[]{GUIType.DROPPER, 0, 1, 2, 3, 4, 5, 6, 7, 8, 3, 3}, + new Object[]{GUIType.FURNACE, 0, 1, 2, 0, 1, 2, 0, 1, 2, 1, 3}, + new Object[]{GUIType.WORKBENCH, 0, 1, 2, 3, 4, 5, 6, 7, 8, 3, 3}, + new Object[]{GUIType.ENCHANTING, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 2}, + new Object[]{GUIType.BREWING, 0, 1, 1, 2, 3, 4, 2, 3, 4, 2, 3}, + new Object[]{GUIType.PLAYER, 0, 4, 8, 9, 13, 17, 27, 31, 35, 4, 9}, + new Object[]{GUIType.ENDER_CHEST, 0, 4, 8, 9, 13, 17, 18, 22, 26, 3, 9}, + new Object[]{GUIType.ANVIL, 0, 1, 2, 0, 1, 2, 0, 1, 2, 1, 3}, + new Object[]{GUIType.SMITHING, 0, 1, 2, 0, 1, 2, 0, 1, 2, 1, 3}, + new Object[]{GUIType.BEACON, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, + new Object[]{GUIType.HOPPER, 0, 2, 4, 0, 2, 4, 0, 2, 4, 1, 5}, + new Object[]{GUIType.SHULKER_BOX, 0, 4, 8, 9, 13, 17, 18, 22, 26, 3, 9}, + new Object[]{GUIType.BARREL, 0, 4, 8, 9, 13, 17, 18, 22, 26, 3, 9}, + new Object[]{GUIType.BLAST_FURNACE, 0, 1, 2, 0, 1, 2, 0, 1, 2, 1, 3}, + new Object[]{GUIType.LECTERN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, + new Object[]{GUIType.SMOKER, 0, 1, 2, 0, 1, 2, 0, 1, 2, 1, 3}, + new Object[]{GUIType.LOOM, 0, 1, 1, 0, 1, 3, 2, 2, 2, 2, 3}, + new Object[]{GUIType.CARTOGRAPHY, 0, 1, 2, 0, 1, 2, 0, 1, 2, 1, 3}, + new Object[]{GUIType.GRINDSTONE, 0, 1, 2, 0, 1, 2, 0, 1, 2, 1, 3}, + new Object[]{GUIType.STONECUTTER, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 2}, }; } @@ -60,7 +60,8 @@ private static Object[][] expectedCorners() { void testGUICorners(Object object, int northWest, int north, int northEast, int middleWest, int middle, int middleEast, - int southWest, int south, int southEast) { + int southWest, int south, int southEast, + int rows, int columns) { GUI gui = new Refl<>(GUI.class).invokeMethod("newGUI", object); assertEquals(northWest, gui.northWest(), "Invalid North West slot"); @@ -74,14 +75,18 @@ void testGUICorners(Object object, assertEquals(southWest, gui.southWest(), "Invalid South West slot"); assertEquals(south, gui.south(), "Invalid South slot"); assertEquals(southEast, gui.southEast(), "Invalid South East slot"); + + assertEquals(rows, gui.rows()); + assertEquals(columns, gui.columns()); } @ParameterizedTest @MethodSource("expectedCorners") void testSetTopSide(Object object, - int northWest, int north, int northEast, - int middleWest, int middle, int middleEast, - int southWest, int south, int southEast) { + int northWest, int north, int northEast, + int middleWest, int middle, int middleEast, + int southWest, int south, int southEast, + int rows, int columns) { final Map ignored = new HashMap<>(); GUI gui = new Refl<>(GUI.class).invokeMethod("newGUI", object); @@ -115,7 +120,8 @@ void testSetTopSide(Object object, void testSetLeftSide(Object object, int northWest, int north, int northEast, int middleWest, int middle, int middleEast, - int southWest, int south, int southEast) { + int southWest, int south, int southEast, + int rows, int columns) { final Map ignored = new HashMap<>(); ignored.put(GUIType.WORKBENCH, 9); ignored.put(GUIType.BREWING, 3); @@ -147,9 +153,10 @@ void testSetLeftSide(Object object, @ParameterizedTest @MethodSource("expectedCorners") void testSetBottomSide(Object object, - int northWest, int north, int northEast, - int middleWest, int middle, int middleEast, - int southWest, int south, int southEast) { + int northWest, int north, int northEast, + int middleWest, int middle, int middleEast, + int southWest, int south, int southEast, + int rows, int columns) { final Map ignored = new HashMap<>(); ignored.put(GUIType.WORKBENCH, 9); ignored.put(GUIType.PLAYER, 36); @@ -184,9 +191,10 @@ void testSetBottomSide(Object object, @ParameterizedTest @MethodSource("expectedCorners") void testSetRightSide(Object object, - int northWest, int north, int northEast, - int middleWest, int middle, int middleEast, - int southWest, int south, int southEast) { + int northWest, int north, int northEast, + int middleWest, int middle, int middleEast, + int southWest, int south, int southEast, + int rows, int columns) { final Map ignored = new HashMap<>(); ignored.put(GUIType.LOOM, 0);