aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java12
-rw-r--r--src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java75
2 files changed, 81 insertions, 6 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java
index e7858f05..a8e62a94 100644
--- a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java
+++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java
@@ -11,12 +11,12 @@ public class Waypoint {
protected static final float DEFAULT_HIGHLIGHT_ALPHA = 0.5f;
protected static final float DEFAULT_LINE_WIDTH = 5f;
public final BlockPos pos;
- private final Box box;
- private final Supplier<Type> typeSupplier;
- private final float[] colorComponents;
- private final float alpha;
- private final float lineWidth;
- private final boolean throughWalls;
+ final Box box;
+ final Supplier<Type> typeSupplier;
+ final float[] colorComponents;
+ final float alpha;
+ final float lineWidth;
+ final boolean throughWalls;
private boolean shouldRender;
protected Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents) {
diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java
new file mode 100644
index 00000000..41f5a530
--- /dev/null
+++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java
@@ -0,0 +1,75 @@
+package de.hysky.skyblocker.utils.waypoint;
+
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Box;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class WaypointTest {
+ private Waypoint.Type type;
+
+ @Test
+ void testDefaultConstructor() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0f, 0.5f, 1f});
+ Assertions.assertEquals(BlockPos.ORIGIN, waypoint.pos);
+ Assertions.assertEquals(new Box(BlockPos.ORIGIN), waypoint.box);
+ Assertions.assertEquals(type, waypoint.typeSupplier.get());
+ Assertions.assertEquals(0f, waypoint.colorComponents[0]);
+ Assertions.assertEquals(0.5f, waypoint.colorComponents[1]);
+ Assertions.assertEquals(1f, waypoint.colorComponents[2]);
+ Assertions.assertEquals(Waypoint.DEFAULT_HIGHLIGHT_ALPHA, waypoint.alpha);
+ Assertions.assertEquals(Waypoint.DEFAULT_LINE_WIDTH, waypoint.lineWidth);
+ Assertions.assertTrue(waypoint.throughWalls);
+ Assertions.assertTrue(waypoint.shouldRender());
+ }
+
+ @Test
+ void testTypeConstructor() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, Waypoint.Type.WAYPOINT, new float[]{0, 0, 0}, Waypoint.DEFAULT_HIGHLIGHT_ALPHA);
+ Assertions.assertEquals(Waypoint.Type.WAYPOINT, waypoint.typeSupplier.get());
+ }
+
+ @Test
+ void testAlphaConstructor() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0}, 1f);
+ Assertions.assertEquals(1f, waypoint.alpha);
+ }
+
+ @Test
+ void testLineWidthConstructor() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0}, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, 10f);
+ Assertions.assertEquals(10f, waypoint.lineWidth);
+ }
+
+ @Test
+ void testThroughWallsConstructor() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0}, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, Waypoint.DEFAULT_LINE_WIDTH, false);
+ Assertions.assertFalse(waypoint.throughWalls);
+ }
+
+ @Test
+ void testShouldRenderConstructor() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0}, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, Waypoint.DEFAULT_LINE_WIDTH, true, false);
+ Assertions.assertFalse(waypoint.shouldRender());
+ }
+
+ @Test
+ void testFound() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0});
+ Assertions.assertTrue(waypoint.shouldRender());
+ waypoint.setFound();
+ Assertions.assertFalse(waypoint.shouldRender());
+ waypoint.setMissing();
+ Assertions.assertTrue(waypoint.shouldRender());
+ }
+
+ @Test
+ void testType() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0});
+ Assertions.assertEquals(type, waypoint.typeSupplier.get());
+ type = Waypoint.Type.WAYPOINT;
+ Assertions.assertEquals(type, waypoint.typeSupplier.get());
+ type = Waypoint.Type.OUTLINED_HIGHLIGHT;
+ Assertions.assertEquals(type, waypoint.typeSupplier.get());
+ }
+}