Current iteration of work.
Attempted at fixing the coordinate converter again. Added more applicable tests for them. Changing to a more stateless design for biome generator. Refactored correcting package name to fit conventions.
This commit is contained in:
@@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
|
||||
import ca.recrown.islandsurvivalcraft.Types.Point2;
|
||||
import ca.recrown.islandsurvivalcraft.types.Point2;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
@@ -85,8 +85,8 @@ public class UtilitiesTest {
|
||||
|
||||
@Test
|
||||
public void testWorldToLocalCoordinatesPositive() {
|
||||
assertEquals(new Point2(6, 2), Utilities.worldToLocalChunkCoordinates(39, 83));
|
||||
assertEquals(new Point2(6, 2), Utilities.worldToLocalChunkCoordinates(new Point2(39, 83)));
|
||||
assertEquals(new Point2(7, 3), Utilities.worldToLocalChunkCoordinates(39, 83));
|
||||
assertEquals(new Point2(7, 3), Utilities.worldToLocalChunkCoordinates(new Point2(39, 83)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,4 +94,31 @@ public class UtilitiesTest {
|
||||
assertEquals(new Point2(0, 0), Utilities.worldToLocalChunkCoordinates(1024, 32));
|
||||
assertEquals(new Point2(0, 0), Utilities.worldToLocalChunkCoordinates(new Point2(16, 80)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWorldToLocalCoordinatesPositiveEntirety() {
|
||||
int chunkX = 4;
|
||||
int chunkZ = 3;
|
||||
for (int x = 0; x < Utilities.CHUNK_SIZE; x++) {
|
||||
for (int z = 0; z < Utilities.CHUNK_SIZE; z++) {
|
||||
int worldX = Utilities.CHUNK_SIZE * chunkX + x;
|
||||
int worldZ = Utilities.CHUNK_SIZE * chunkZ + z;
|
||||
assertEquals(new Point2(x, z), Utilities.worldToLocalChunkCoordinates(new Point2(worldX, worldZ)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWorldToLocalCoordinatesNegativeEntirety() {
|
||||
int chunkX = -42;
|
||||
int chunkZ = -3;
|
||||
for (int x = 0; x < Utilities.CHUNK_SIZE; x++) {
|
||||
for (int z = 0; z < Utilities.CHUNK_SIZE; z++) {
|
||||
int worldX = Utilities.CHUNK_SIZE * chunkX + x;
|
||||
int worldZ = Utilities.CHUNK_SIZE * chunkZ + z;
|
||||
assertEquals(new Point2(x, z), Utilities.worldToLocalChunkCoordinates(new Point2(worldX, worldZ)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user