Skip to content

Commit

Permalink
Added rows and columns tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fulminazzo committed Apr 17, 2024
1 parent a0bb84f commit b1a8ad8
Showing 1 changed file with 47 additions and 39 deletions.
86 changes: 47 additions & 39 deletions gui/base/src/test/java/it/angrybear/yagl/guis/GUITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
}

Expand All @@ -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");
Expand All @@ -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<Object, Integer> ignored = new HashMap<>();

GUI gui = new Refl<>(GUI.class).invokeMethod("newGUI", object);
Expand Down Expand Up @@ -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<Object, Integer> ignored = new HashMap<>();
ignored.put(GUIType.WORKBENCH, 9);
ignored.put(GUIType.BREWING, 3);
Expand Down Expand Up @@ -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<Object, Integer> ignored = new HashMap<>();
ignored.put(GUIType.WORKBENCH, 9);
ignored.put(GUIType.PLAYER, 36);
Expand Down Expand Up @@ -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<Object, Integer> ignored = new HashMap<>();
ignored.put(GUIType.LOOM, 0);

Expand Down

0 comments on commit b1a8ad8

Please sign in to comment.