From e440bb72d80da655d99a35a618230036883b6e0b Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 12 Nov 2023 18:00:44 -0500 Subject: Add waypoint tests --- .../skyblocker/utils/waypoint/WaypointTest.java | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java (limited to 'src/test/java') 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()); + } +} -- cgit From 4f04a35ae3300656a4ef92e0a62304d58aa582a2 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Mon, 13 Nov 2023 18:28:15 -0500 Subject: Add Profile Aware Waypoint --- .../utils/waypoint/ProfileAwareWaypointTest.java | 38 ++++++++++++++++++++++ .../skyblocker/utils/waypoint/WaypointTest.java | 17 +++++----- 2 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java (limited to 'src/test/java') diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java new file mode 100644 index 00000000..9dc5b2b9 --- /dev/null +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java @@ -0,0 +1,38 @@ +package de.hysky.skyblocker.utils.waypoint; + +import net.minecraft.util.math.BlockPos; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ProfileAwareWaypointTest { + @Test + void testShouldRender() { + ProfileAwareWaypoint waypoint = new ProfileAwareWaypoint(BlockPos.ORIGIN, null, null, null); + waypoint.setFound("profile"); + Assertions.assertTrue(waypoint.shouldRender()); + waypoint.setFound(""); + Assertions.assertFalse(waypoint.shouldRender()); + waypoint.setMissing(); + Assertions.assertTrue(waypoint.shouldRender()); + } + + @Test + void testGetColorComponents() { + ProfileAwareWaypoint waypoint = new ProfileAwareWaypoint(BlockPos.ORIGIN, null, new float[]{0f, 0.5f, 1f}, new float[]{1f, 0.5f, 0f}); + waypoint.setFound("profile"); + float[] colorComponents = waypoint.getColorComponents(); + Assertions.assertEquals(0f, colorComponents[0]); + Assertions.assertEquals(0.5f, colorComponents[1]); + Assertions.assertEquals(1f, colorComponents[2]); + waypoint.setFound(""); + colorComponents = waypoint.getColorComponents(); + Assertions.assertEquals(1f, colorComponents[0]); + Assertions.assertEquals(0.5f, colorComponents[1]); + Assertions.assertEquals(0f, colorComponents[2]); + waypoint.setMissing(); + colorComponents = waypoint.getColorComponents(); + Assertions.assertEquals(0f, colorComponents[0]); + Assertions.assertEquals(0.5f, colorComponents[1]); + Assertions.assertEquals(1f, colorComponents[2]); + } +} diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java index 41f5a530..b3be64b7 100644 --- a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java @@ -7,10 +7,11 @@ import org.junit.jupiter.api.Test; public class WaypointTest { private Waypoint.Type type; + private final float[] colorComponents = new float[]{0f, 0.5f, 1f}; @Test void testDefaultConstructor() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0f, 0.5f, 1f}); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents); Assertions.assertEquals(BlockPos.ORIGIN, waypoint.pos); Assertions.assertEquals(new Box(BlockPos.ORIGIN), waypoint.box); Assertions.assertEquals(type, waypoint.typeSupplier.get()); @@ -25,37 +26,37 @@ public class WaypointTest { @Test void testTypeConstructor() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, Waypoint.Type.WAYPOINT, new float[]{0, 0, 0}, Waypoint.DEFAULT_HIGHLIGHT_ALPHA); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, Waypoint.Type.WAYPOINT, colorComponents, 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); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, 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); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, 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); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, 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); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, 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}); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents); Assertions.assertTrue(waypoint.shouldRender()); waypoint.setFound(); Assertions.assertFalse(waypoint.shouldRender()); @@ -65,7 +66,7 @@ public class WaypointTest { @Test void testType() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0}); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents); Assertions.assertEquals(type, waypoint.typeSupplier.get()); type = Waypoint.Type.WAYPOINT; Assertions.assertEquals(type, waypoint.typeSupplier.get()); -- cgit From 9a86f3c5297c0e597abce80222db8ef9c42fbe8e Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Mon, 13 Nov 2023 20:45:27 -0500 Subject: Refactor more waypoints --- src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java index b3be64b7..d8839951 100644 --- a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java @@ -30,12 +30,6 @@ public class WaypointTest { Assertions.assertEquals(Waypoint.Type.WAYPOINT, waypoint.typeSupplier.get()); } - @Test - void testAlphaConstructor() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, 1f); - Assertions.assertEquals(1f, waypoint.alpha); - } - @Test void testLineWidthConstructor() { Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, 10f); -- cgit