mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-18 07:12:15 -08:00
New tests / Bugfixes
This commit is contained in:
parent
08a2872527
commit
9699d9467a
21 changed files with 190 additions and 71 deletions
68
tests/src/test/java/ZoneTests.java
Normal file
68
tests/src/test/java/ZoneTests.java
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.ObjectSet;
|
||||
import io.anuke.arc.util.Structs;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Zone;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.storage.CoreBlock;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
|
||||
|
||||
public class ZoneTests{
|
||||
|
||||
@BeforeAll
|
||||
static void launchApplication(){
|
||||
ApplicationTests.launchApplication();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void resetWorld(){
|
||||
Time.setDeltaProvider(() -> 1f);
|
||||
logic.reset();
|
||||
state.set(State.menu);
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
DynamicTest[] testZoneResources(){
|
||||
Array<DynamicTest> out = new Array<>();
|
||||
|
||||
for(Zone zone : content.zones()){
|
||||
out.add(dynamicTest(zone.name, () -> {
|
||||
logic.reset();
|
||||
world.loadGenerator(zone.generator);
|
||||
ObjectSet<Item> resources = new ObjectSet<>();
|
||||
boolean hasSpawnPoint = false;
|
||||
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
for(int y = 0; y < world.height(); y++){
|
||||
Tile tile = world.tile(x, y);
|
||||
if(tile.drop() != null){
|
||||
resources.add(tile.drop());
|
||||
}
|
||||
if(tile.block() instanceof CoreBlock){
|
||||
hasSpawnPoint = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue(hasSpawnPoint, "Zone \"" + zone.name + "\" has no spawn points.");
|
||||
//assertTrue(world.spawner.countSpawns() > 0, "Zone \"" + zone.name + "\" has no enemy spawn points: " + world.spawner.countSpawns());
|
||||
|
||||
for(Item item : resources){
|
||||
assertTrue(Structs.contains(zone.resources, item), "Zone \"" + zone.name + "\" is missing item in resource list: \"" + item.name + "\"");
|
||||
}
|
||||
|
||||
for(Item item : zone.resources){
|
||||
assertTrue(resources.contains(item), "Zone \"" + zone.name + "\" has unnecessary item in resoruce list: \"" + item.name + "\"");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
return out.toArray(DynamicTest.class);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue