|
| 1 | +package com.kevinthegreat.skyblockmod.waypoint; |
| 2 | + |
| 3 | +import net.minecraft.util.math.BlockPos; |
| 4 | +import net.minecraft.util.math.Box; |
| 5 | +import org.junit.jupiter.api.Assertions; |
| 6 | +import org.junit.jupiter.api.Test; |
| 7 | + |
| 8 | +public class WaypointTest { |
| 9 | + private Waypoint.Type type; |
| 10 | + private final float[] colorComponents = new float[]{0f, 0.5f, 1f}; |
| 11 | + |
| 12 | + @Test |
| 13 | + void testDefaultConstructor() { |
| 14 | + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents); |
| 15 | + Assertions.assertEquals(BlockPos.ORIGIN, waypoint.pos); |
| 16 | + Assertions.assertEquals(new Box(BlockPos.ORIGIN), waypoint.box); |
| 17 | + Assertions.assertEquals(type, waypoint.typeSupplier.get()); |
| 18 | + Assertions.assertEquals(0f, waypoint.colorComponents[0]); |
| 19 | + Assertions.assertEquals(0.5f, waypoint.colorComponents[1]); |
| 20 | + Assertions.assertEquals(1f, waypoint.colorComponents[2]); |
| 21 | + Assertions.assertEquals(Waypoint.DEFAULT_HIGHLIGHT_ALPHA, waypoint.alpha); |
| 22 | + Assertions.assertEquals(Waypoint.DEFAULT_LINE_WIDTH, waypoint.lineWidth); |
| 23 | + Assertions.assertTrue(waypoint.throughWalls); |
| 24 | + Assertions.assertTrue(waypoint.shouldRender()); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + void testTypeConstructor() { |
| 29 | + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, Waypoint.Type.WAYPOINT, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA); |
| 30 | + Assertions.assertEquals(Waypoint.Type.WAYPOINT, waypoint.typeSupplier.get()); |
| 31 | + } |
| 32 | + |
| 33 | + @Test |
| 34 | + void testLineWidthConstructor() { |
| 35 | + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, 10f); |
| 36 | + Assertions.assertEquals(10f, waypoint.lineWidth); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + void testThroughWallsConstructor() { |
| 41 | + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, Waypoint.DEFAULT_LINE_WIDTH, false); |
| 42 | + Assertions.assertFalse(waypoint.throughWalls); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + void testShouldRenderConstructor() { |
| 47 | + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, Waypoint.DEFAULT_LINE_WIDTH, true, false); |
| 48 | + Assertions.assertFalse(waypoint.shouldRender()); |
| 49 | + } |
| 50 | + |
| 51 | + @Test |
| 52 | + void testFound() { |
| 53 | + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents); |
| 54 | + Assertions.assertTrue(waypoint.shouldRender()); |
| 55 | + waypoint.setFound(); |
| 56 | + Assertions.assertFalse(waypoint.shouldRender()); |
| 57 | + waypoint.setMissing(); |
| 58 | + Assertions.assertTrue(waypoint.shouldRender()); |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + void testType() { |
| 63 | + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents); |
| 64 | + Assertions.assertEquals(type, waypoint.typeSupplier.get()); |
| 65 | + type = Waypoint.Type.WAYPOINT; |
| 66 | + Assertions.assertEquals(type, waypoint.typeSupplier.get()); |
| 67 | + type = Waypoint.Type.OUTLINED_HIGHLIGHT; |
| 68 | + Assertions.assertEquals(type, waypoint.typeSupplier.get()); |
| 69 | + } |
| 70 | +} |
0 commit comments