Archived
0

поправлены тесты

убраны заигноренные, упрощены для чтения действующие
This commit is contained in:
2018-12-17 11:34:38 +03:00
parent 3dda554632
commit e1427c8db6

View File

@@ -1,62 +1,25 @@
package mc.world.anvil;
import com.google.common.collect.Lists;
import mc.core.world.block.Block;
import mc.core.world.block.BlockType;
import mc.core.world.chunk.Chunk;
import mc.core.world.chunk.ChunkSection;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
class RegionTest {
private static Region region;
private static List<BlockType> layersBlock;
@BeforeAll
static void before() throws URISyntaxException, IOException {
region = new Region(Paths.get(RegionTest.class.getResource("/region/r.0.0.mca").toURI()).toFile());
layersBlock = Lists.newArrayList(
BlockType.BEDROCK,
BlockType.DIRT,
BlockType.DIRT,
BlockType.GRASS
);
}
@Test
@Disabled
void getChunk() {
for (int cZ = 0; cZ < 32; cZ++) {
for (int cX = 0; cX < 32; cX++) {
Chunk chunk = region.getChunk(cX, cZ);
assertNotNull(chunk);
ChunkSection chunkSection = chunk.getChunkSection(0);
assertNotNull(chunkSection);
for (int y = 0; y < 16; y++) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
Block block = chunkSection.getBlock(x, y, z);
if (y > layersBlock.size()-1) {
assertEquals(BlockType.AIR, block.getBlockType(), String.format("coords: %d %d %d", x+(cX*16), y, z+(cZ*16)));
} else {
assertEquals(layersBlock.get(y), block.getBlockType(), String.format("coords: %d %d %d", x+(cX*16), y, z+(cZ*16)));
}
}
}
}
}
}
}
@Test
@@ -66,7 +29,15 @@ class RegionTest {
ChunkSection chunkSection = chunk.getChunkSection(0);
assertNotNull(chunkSection);
checkSection1(chunkSection);
chunkSection = chunk.getChunkSection(1);
assertNotNull(chunkSection);
checkSection2(chunkSection);
}
private void checkSection1(ChunkSection chunkSection) {
for (int y = 0; y < 16; y++) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
@@ -89,10 +60,9 @@ class RegionTest {
}
}
}
}
chunkSection = chunk.getChunkSection(1);
assertNotNull(chunkSection);
private void checkSection2(ChunkSection chunkSection) {
for (int y = 0; y < 16; y++) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {