обновлен тест CompactedCoords
This commit is contained in:
@@ -3,40 +3,21 @@ package mc.core.utils;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
public class TestCompactedCoords {
|
public class TestCompactedCoords {
|
||||||
@Test
|
@Test
|
||||||
public void testXZSimple() {
|
public void testXZ() {
|
||||||
for (int z = -100; z <= 100; z++) {
|
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||||
for (int x = -100; x <= 100; x++) {
|
|
||||||
int compressXZ = CompactedCoords.compressXZ(x, z);
|
|
||||||
int[] xz = CompactedCoords.uncompressXZ(compressXZ);
|
|
||||||
|
|
||||||
assertEquals(x, xz[0]);
|
|
||||||
assertEquals(z, xz[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testXZRandom() {
|
|
||||||
Random random = new Random();
|
|
||||||
int x,z;
|
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
do {
|
final int x = random.nextInt(Short.MIN_VALUE, Short.MAX_VALUE);
|
||||||
x = random.nextInt();
|
final int z = random.nextInt(Short.MIN_VALUE, Short.MAX_VALUE);
|
||||||
} while (x < Short.MIN_VALUE || x > Short.MAX_VALUE);
|
|
||||||
|
|
||||||
do {
|
final int compressXZ = CompactedCoords.compressXZ(x, z);
|
||||||
z = random.nextInt();
|
|
||||||
} while (z < Short.MIN_VALUE || z > Short.MAX_VALUE);
|
|
||||||
|
|
||||||
|
|
||||||
int compressXZ = CompactedCoords.compressXZ(x, z);
|
|
||||||
int[] xz = CompactedCoords.uncompressXZ(compressXZ);
|
int[] xz = CompactedCoords.uncompressXZ(compressXZ);
|
||||||
|
|
||||||
assertEquals(x, xz[0]);
|
assertEquals(x, xz[0]);
|
||||||
|
|||||||
Reference in New Issue
Block a user