-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into minor-refactor
- Loading branch information
Showing
5 changed files
with
110 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "automatic", | ||
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable" | ||
} | ||
"java.configuration.updateBuildConfiguration": "automatic", | ||
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable ", | ||
"java.test.config": [ | ||
{ | ||
"name": "WPIlibUnitTests", | ||
"vmargs": ["-Dnohaljni=true"] | ||
} | ||
], | ||
"java.test.defaultConfig": "WPIlibUnitTests" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
Pathfinding/src/test/java/me/nabdev/pathfinding/PathfinderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package me.nabdev.pathfinding; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import me.nabdev.pathfinding.structures.ImpossiblePathException; | ||
import me.nabdev.pathfinding.structures.Vector; | ||
import me.nabdev.pathfinding.structures.Vertex; | ||
import me.nabdev.pathfinding.utilities.FieldLoader.Field; | ||
|
||
public class PathfinderTest { | ||
Pathfinder pathfinder; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
pathfinder = new PathfinderBuilder(Field.CRESCENDO_2024).build(); | ||
} | ||
|
||
@Test | ||
@DisplayName("Impossible Path Should Throw Exception") | ||
void impossiblePath() { | ||
assertThrows(ImpossiblePathException.class, | ||
() -> pathfinder.generatePath(new Vertex(-2, -2), new Vertex(2, 2))); | ||
} | ||
|
||
@Test | ||
@DisplayName("Pathfinder Should Generate Path") | ||
void generatePath() { | ||
assertDoesNotThrow(() -> pathfinder.generatePath(new Vertex(2, 2), new Vertex(4, 4))); | ||
} | ||
|
||
@Test | ||
@DisplayName("Diagonal Intersection") | ||
void diagonalIntersect() { | ||
assertTrue(Vector.dotIntersectFast(new Vertex(0, 0), new Vertex(10, 10), new Vertex(0, 10), new Vertex(10, 0))); | ||
} | ||
|
||
@Test | ||
@DisplayName("One vertex intersection") | ||
void oneVertexIntersect() { | ||
assertTrue( | ||
Vector.dotIntersectFast(new Vertex(0, 0), new Vertex(10, 10), new Vertex(0, 10), new Vertex(10, 10))); | ||
} | ||
|
||
@Test | ||
@DisplayName("Perpendicular intersection") | ||
void perpendicularIntersect() { | ||
assertTrue( | ||
Vector.dotIntersectFast(new Vertex(5, 0), new Vertex(5, 10), new Vertex(0, 5), new Vertex(10, 5))); | ||
} | ||
|
||
// I'm aware this test does not pass, but it will be fixed later with a new | ||
// intersection algorithm | ||
|
||
// @Test | ||
// @DisplayName("Perpendicular One Vertex intersection") | ||
// void perpendicularIntersectOne() { | ||
// assertTrue( | ||
// Vector.dotIntersectFast(new Vertex(5, 0), new Vertex(5, 5), new Vertex(0, 5), | ||
// new Vertex(10, 5))); | ||
// } | ||
|
||
@Test | ||
@DisplayName("Diagonal Non-Intersection") | ||
void diagonalNonIntersect() { | ||
assertTrue(Vector.dotIntersectFast(new Vertex(0, 0), new Vertex(10, 10), new Vertex(0, 10), new Vertex(10, 0))); | ||
} | ||
|
||
@Test | ||
@DisplayName("Perpendicular Non-intersection") | ||
void perpendicularNonIntersect() { | ||
assertFalse( | ||
Vector.dotIntersectFast(new Vertex(5, 0), new Vertex(5, 4), new Vertex(0, 5), new Vertex(10, 5))); | ||
} | ||
|
||
} |