метод теста поделен на мелкие методы
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package mc.core.network.proto_1_12_2.packets;
|
||||
|
||||
import mc.core.network.proto_1_12_2.ByteArrayOutputNetStream;
|
||||
import mc.core.network.proto_1_12_2.packets.DumbChunkData.DumbChunkSection;
|
||||
import mc.core.world.Biome;
|
||||
import mc.core.world.block.BlockFactory;
|
||||
import mc.core.world.block.BlockType;
|
||||
@@ -124,44 +125,57 @@ class ChunkDataPacketTest {
|
||||
assertEquals(expectedDumbChunkData.getData().length, actualDumbChunkData.getData().length);
|
||||
|
||||
for (int numberSection = 0; numberSection < expectedDumbChunkData.getData().length; numberSection++) {
|
||||
final DumbChunkData.DumbChunkSection expectedDumbChunkSection = expectedDumbChunkData.getData()[numberSection];
|
||||
final DumbChunkData.DumbChunkSection actualDumbChunkSection = actualDumbChunkData.getData()[numberSection];
|
||||
final DumbChunkSection expectedDumbChunkSection = expectedDumbChunkData.getData()[numberSection];
|
||||
final DumbChunkSection actualDumbChunkSection = actualDumbChunkData.getData()[numberSection];
|
||||
|
||||
// Palette
|
||||
assertEquals(expectedDumbChunkSection.getBitsPerBlock(), actualDumbChunkSection.getBitsPerBlock());
|
||||
|
||||
if (expectedDumbChunkSection.getPalette().size() > actualDumbChunkSection.getPalette().size()) {
|
||||
for (int j = 0; j < actualDumbChunkSection.getPalette().size(); j++) {
|
||||
assertTrue(expectedDumbChunkSection.getPalette().contains(
|
||||
actualDumbChunkSection.getPalette().get(j)
|
||||
), String.format("[%d] Palette not contains %s", numberSection, actualDumbChunkSection.getPalette().get(j)));
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < expectedDumbChunkSection.getPalette().size(); j++) {
|
||||
assertTrue(actualDumbChunkSection.getPalette().contains(
|
||||
expectedDumbChunkSection.getPalette().get(j)
|
||||
), String.format("[%d] Palette not contains %s", numberSection, actualDumbChunkSection.getPalette().get(j)));
|
||||
}
|
||||
}
|
||||
testPalette(expectedDumbChunkSection, actualDumbChunkSection, numberSection);
|
||||
|
||||
// Data
|
||||
assertEquals(expectedDumbChunkSection.getData().size(), actualDumbChunkSection.getData().size());
|
||||
testDataBlock(expectedDumbChunkSection, actualDumbChunkSection, numberSection);
|
||||
|
||||
for (int j = 0; j < expectedDumbChunkSection.getData().size(); j++) {
|
||||
assertEquals(
|
||||
expectedDumbChunkSection.getData().get(j),
|
||||
actualDumbChunkSection.getData().get(j),
|
||||
String.format("[%d] Data (blocks)", numberSection)
|
||||
);
|
||||
}
|
||||
|
||||
// Block light
|
||||
assertArrayEquals(expectedDumbChunkSection.getBlockLight(), actualDumbChunkSection.getBlockLight(),
|
||||
String.format("[%d] Block light", numberSection));
|
||||
|
||||
// Sky light
|
||||
assertArrayEquals(expectedDumbChunkSection.getSkyLight(), actualDumbChunkSection.getSkyLight(),
|
||||
String.format("[%d] Sky light", numberSection));
|
||||
// Block and Sky light
|
||||
testLight(expectedDumbChunkSection, actualDumbChunkSection, numberSection);
|
||||
}
|
||||
}
|
||||
|
||||
private void testPalette(DumbChunkSection expected, DumbChunkSection actual, int numberSection) {
|
||||
assertEquals(expected.getBitsPerBlock(), actual.getBitsPerBlock());
|
||||
|
||||
if (expected.getPalette().size() > actual.getPalette().size()) {
|
||||
for (int j = 0; j < actual.getPalette().size(); j++) {
|
||||
assertTrue(expected.getPalette().contains(
|
||||
actual.getPalette().get(j)
|
||||
), String.format("[%d] Palette not contains %s", numberSection, actual.getPalette().get(j)));
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < expected.getPalette().size(); j++) {
|
||||
assertTrue(actual.getPalette().contains(
|
||||
expected.getPalette().get(j)
|
||||
), String.format("[%d] Palette not contains %s", numberSection, actual.getPalette().get(j)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void testDataBlock(DumbChunkSection expected, DumbChunkSection actual, int numberSection) {
|
||||
assertEquals(expected.getData().size(), actual.getData().size());
|
||||
|
||||
for (int j = 0; j < expected.getData().size(); j++) {
|
||||
assertEquals(
|
||||
expected.getData().get(j),
|
||||
actual.getData().get(j),
|
||||
String.format("[%d] Data (blocks)", numberSection)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void testLight(DumbChunkSection expected, DumbChunkSection actual, int numberSection) {
|
||||
// Block light
|
||||
assertArrayEquals(expected.getBlockLight(), actual.getBlockLight(),
|
||||
String.format("[%d] Block light", numberSection));
|
||||
|
||||
// Sky light
|
||||
assertArrayEquals(expected.getSkyLight(), actual.getSkyLight(),
|
||||
String.format("[%d] Sky light", numberSection));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user