Archived
0

параметеризирован RegionTest

This commit is contained in:
2018-12-30 15:07:25 +03:00
parent 7c9764f763
commit 56888c63a1

View File

@@ -10,9 +10,12 @@ import mc.core.world.block.BlockType;
import mc.core.world.chunk.Chunk; import mc.core.world.chunk.Chunk;
import mc.core.world.chunk.ChunkSection; import mc.core.world.chunk.ChunkSection;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -26,22 +29,9 @@ class RegionTest {
region = new Region(Paths.get(RegionTest.class.getResource("/region/r.0.0.mca").toURI()).toFile()); region = new Region(Paths.get(RegionTest.class.getResource("/region/r.0.0.mca").toURI()).toFile());
} }
@Test private static Stream<Arguments> streamArguments() {
void getChunkSection() { ChunkChecker chunkChecker00 = new ChunkChecker() {
final Chunk chunk = region.getChunk(0, 0); private void checkSection0(ChunkSection chunkSection) {
assertNotNull(chunk);
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 y = 0; y < 16; y++) {
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
@@ -74,7 +64,7 @@ class RegionTest {
return new CompoundTag("", compoundMap); return new CompoundTag("", compoundMap);
} }
private void checkSection2(ChunkSection chunkSection) { private void checkSection1(ChunkSection chunkSection) {
for (int y = 0; y < 16; y++) { for (int y = 0; y < 16; y++) {
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
@@ -107,4 +97,34 @@ class RegionTest {
} }
} }
} }
@Override
public void check(Chunk chunk) {
ChunkSection chunkSection = chunk.getChunkSection(0);
assertNotNull(chunkSection);
checkSection0(chunkSection);
chunkSection = chunk.getChunkSection(1);
assertNotNull(chunkSection);
checkSection1(chunkSection);
}
};
return Stream.of(
Arguments.of(0, 0, chunkChecker00)
);
}
@ParameterizedTest
@MethodSource("streamArguments")
void getChunkSection(int chunkX, int chunkZ, ChunkChecker chunkChecker) {
final Chunk chunk = region.getChunk(chunkX, chunkZ);
assertNotNull(chunk);
chunkChecker.check(chunk);
}
interface ChunkChecker {
void check(Chunk chunk);
}
} }