refactor(command): clean GSD comments and translate user-facing messages to English
This commit is contained in:
@@ -6,21 +6,9 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Pure-data tests for {@link DefineValidation} — no Hytale runtime dependency.
|
||||
*
|
||||
* <p>Covers :
|
||||
* <ul>
|
||||
* <li>Name regex accepts alnum + underscore + dash, 1..32 chars.</li>
|
||||
* <li>Name regex rejects blank, spaces, special chars, non-ASCII, over-length.</li>
|
||||
* <li>Componentwise min/max return smallest/largest per axis.</li>
|
||||
* <li>Inflate-max-by-1 convention (max block is INSIDE the AABB only if we add 1 per axis).</li>
|
||||
* </ul>
|
||||
*/
|
||||
/** Pure-data tests for {@link DefineValidation} — name regex, componentwise min/max, inflate-max-by-1 convention. */
|
||||
class DefineValidationTest {
|
||||
|
||||
// ---------- name regex ----------
|
||||
|
||||
@Test
|
||||
void validName_acceptsAlnumUnderscoreDash() {
|
||||
assertTrue(DefineValidation.isValidName("abc"));
|
||||
@@ -36,7 +24,7 @@ class DefineValidationTest {
|
||||
assertFalse(DefineValidation.isValidName(""));
|
||||
assertFalse(DefineValidation.isValidName(" "));
|
||||
assertFalse(DefineValidation.isValidName("my zone"));
|
||||
assertFalse(DefineValidation.isValidName("nom avec espaces"));
|
||||
assertFalse(DefineValidation.isValidName("name with spaces"));
|
||||
assertFalse(DefineValidation.isValidName("a\tb"));
|
||||
assertFalse(DefineValidation.isValidName(" leading"));
|
||||
assertFalse(DefineValidation.isValidName("trailing "));
|
||||
@@ -47,8 +35,6 @@ class DefineValidationTest {
|
||||
assertFalse(DefineValidation.isValidName("has.dot"));
|
||||
}
|
||||
|
||||
// ---------- componentwise min/max ----------
|
||||
|
||||
@Test
|
||||
void componentwiseMin_returnsSmallestPerAxis() {
|
||||
int[] a = {5, 10, -3};
|
||||
@@ -75,22 +61,13 @@ class DefineValidationTest {
|
||||
DefineValidation.componentwiseMax(b, a));
|
||||
}
|
||||
|
||||
// ---------- inflate-max convention (block inclusion) ----------
|
||||
|
||||
/**
|
||||
* A block occupies the cube between (x,y,z) and (x+1,y+1,z+1). If an AABB's max is the
|
||||
* raw block coord (maxBlockX, maxBlockY, maxBlockZ), a player standing on top of that
|
||||
* block is OUTSIDE the AABB. We therefore inflate max by +1 per axis.
|
||||
*/
|
||||
/** Blocks occupy the unit cube [x,x+1], so max must be inflated by +1 per axis to include the max block. */
|
||||
@Test
|
||||
void boxFromCorners_inflateMax_includesMaxBlock() {
|
||||
int[] mn = {0, 64, 0};
|
||||
int[] mx = {10, 70, 10};
|
||||
// Player feet at (10.5, 70.5, 10.5) — standing in the maxBlock cube.
|
||||
double px = 10.5, py = 70.5, pz = 10.5;
|
||||
// Without inflate: max = (10,70,10) — player OUT.
|
||||
assertFalse(px < mx[0] && py < mx[1] && pz < mx[2]);
|
||||
// With inflate: max = (11,71,11) — player IN.
|
||||
int[] mxInflated = {mx[0] + 1, mx[1] + 1, mx[2] + 1};
|
||||
assertTrue(px < mxInflated[0] && py < mxInflated[1] && pz < mxInflated[2]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user