diff options
author | olim <bobq4582@gmail.com> | 2024-01-31 15:46:34 +0000 |
---|---|---|
committer | olim <bobq4582@gmail.com> | 2024-01-31 15:46:34 +0000 |
commit | 43d683c782addcbadbe4988e493cc27c91810bc7 (patch) | |
tree | 452d78f26b3e4581e838a333b79e00ce673be1b1 | |
parent | 7076875f3b9b513a569760f5890202e260fc6bd7 (diff) | |
download | Skyblocker-43d683c782addcbadbe4988e493cc27c91810bc7.tar.gz Skyblocker-43d683c782addcbadbe4988e493cc27c91810bc7.tar.bz2 Skyblocker-43d683c782addcbadbe4988e493cc27c91810bc7.zip |
add tests
add tests for the maps location transformation function and the location manager valid location and LocaitonMessage functions
4 files changed, 53 insertions, 3 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java index 9212d74f..6b26d043 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java @@ -102,7 +102,7 @@ public class CrystalsHud { * @param z the world Z coordinate * @return the pair of values for x and y */ - private static Pair<Integer, Integer> transformLocation(double x, double z){ + protected static Pair<Integer, Integer> transformLocation(double x, double z){ //converts an x and z to a location on the map int transformedX = (int)((x-202)/621 * 62); int transformedY = (int)((z -202)/621 * 62); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java index d7deed25..eb68ed9f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -97,7 +97,7 @@ public class CrystalsLocationsManager { client.player.sendMessage(getLocationInputText(location), false); } } - private static Boolean checkInCrystals(BlockPos pos){ + protected static Boolean checkInCrystals(BlockPos pos){ //checks if a location is inside crystal hollows bounds return pos.getX() >= 202 && pos.getX() <= 823 && pos.getZ() >= 202 && pos.getZ() <= 823 @@ -114,7 +114,7 @@ public class CrystalsLocationsManager { ) ); } - private static Text getSetLocationMessage(String location,BlockPos blockPos) { + protected static Text getSetLocationMessage(String location,BlockPos blockPos) { MutableText text = Text.empty(); text.append(Text.literal("Added waypoint for ")); Color locationColor = WAYPOINTLOCATIONS.get(location).color; diff --git a/src/test/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudTest.java b/src/test/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudTest.java new file mode 100644 index 00000000..3086a3e4 --- /dev/null +++ b/src/test/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudTest.java @@ -0,0 +1,19 @@ +package de.hysky.skyblocker.skyblock.dwarven; + +import it.unimi.dsi.fastutil.Pair; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class CrystalsHudTest { + + @Test + void testLocationTransformation(){ + Assertions.assertEquals(CrystalsHud.transformLocation(202,202), Pair.of(0,0)); + Assertions.assertEquals(CrystalsHud.transformLocation(823,823), Pair.of(62,62)); + + Assertions.assertEquals(CrystalsHud.transformLocation(512.5,512.5), Pair.of(31,31)); + + Assertions.assertEquals(CrystalsHud.transformLocation(-50,-50), Pair.of(0,0)); + Assertions.assertEquals(CrystalsHud.transformLocation(1000,1000), Pair.of(62,62)); + } +} diff --git a/src/test/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationManagerTest.java b/src/test/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationManagerTest.java new file mode 100644 index 00000000..592e5ecb --- /dev/null +++ b/src/test/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationManagerTest.java @@ -0,0 +1,31 @@ +package de.hysky.skyblocker.skyblock.dwarven; + +import net.minecraft.text.Text; +import net.minecraft.util.math.BlockPos; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class CrystalsLocationManagerTest { + + @Test + void testLocationInCrystals(){ + Assertions.assertTrue(CrystalsLocationsManager.checkInCrystals(new BlockPos(512,70,512))); + + Assertions.assertTrue(CrystalsLocationsManager.checkInCrystals(new BlockPos(202,31,202))); + Assertions.assertTrue(CrystalsLocationsManager.checkInCrystals(new BlockPos(823,188,823))); + + Assertions.assertFalse(CrystalsLocationsManager.checkInCrystals(new BlockPos(201,31,202))); + Assertions.assertFalse(CrystalsLocationsManager.checkInCrystals(new BlockPos(202,30,202))); + Assertions.assertFalse(CrystalsLocationsManager.checkInCrystals(new BlockPos(202,31,201))); + + Assertions.assertFalse(CrystalsLocationsManager.checkInCrystals(new BlockPos(824,188,823))); + Assertions.assertFalse(CrystalsLocationsManager.checkInCrystals(new BlockPos(823,189,823))); + Assertions.assertFalse(CrystalsLocationsManager.checkInCrystals(new BlockPos(823,188,824))); + } + + @Test + void testSetLocationMessage(){ + Assertions.assertEquals(CrystalsLocationsManager.getSetLocationMessage("Jungle Temple",new BlockPos(10,11,12)).getString(), "Added waypoint for Jungle Temple at : 10 11 12."); + Assertions.assertEquals(CrystalsLocationsManager.getSetLocationMessage("Fairy Grotto",new BlockPos(0,0,0)).getString(), "Added waypoint for Fairy Grotto at : 0 0 0."); + } +} |