This commit is contained in:
Anuken
2019-02-14 10:00:17 -05:00
parent 8c6c4c2630
commit 66766b43c7
9 changed files with 993 additions and 970 deletions

View File

@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class IOTests{
@ -28,7 +29,7 @@ public class IOTests{
ByteBuffer buffer = ByteBuffer.allocate(500);
TypeIO.writeString(buffer, null);
buffer.position(0);
assertEquals(TypeIO.readString(buffer), null);
assertNull(TypeIO.readString(buffer));
}
}

View File

@ -16,13 +16,13 @@ public class DirectConsumerTests extends PowerTestFixture{
@Test
void noPowerRequestedWithNoItems(){
testUnitFactory(0, 0, 0.08f, 0.08f, 1f);
testUnitFactory(0, 0, 0.08f, 0.08f, 0f);
}
@Test
void noPowerRequestedWithInsufficientItems(){
testUnitFactory(30, 0, 0.08f, 0.08f, 1f);
testUnitFactory(0, 30, 0.08f, 0.08f, 1f);
testUnitFactory(30, 0, 0.08f, 0.08f, 0f);
testUnitFactory(0, 30, 0.08f, 0.08f, 0f);
}
@Test

View File

@ -89,7 +89,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
assertTrue(generator.acceptLiquid(tile, null, liquid, availableLiquidAmount), inputType + " | " + parameterDescription + ": Liquids which will be declined by the generator don't need to be tested - The code won't be called for those cases.");
entity.liquids.add(liquid, availableLiquidAmount);
entity.cons.update(tile.entity);
entity.cons.update();
assertTrue(entity.cons.valid());
// Perform an update on the generator once - This should use up any resource up to the maximum liquid usage
@ -134,7 +134,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
if(amount > 0){
entity.items.add(item, amount);
}
entity.cons.update(tile.entity);
entity.cons.update();
assertTrue(entity.cons.valid());
// Perform an update on the generator once - This should use up one or zero items - dependent on if the item is accepted and available or not.
@ -161,7 +161,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
// Burn a single coal and test for the duration
entity.items.add(Items.coal, 1);
entity.cons.update(tile.entity);
entity.cons.update();
generator.update(tile);
float expectedEfficiency = entity.productionEfficiency;

View File

@ -85,7 +85,7 @@ public class PowerTestFixture{
// Simulate the "changed" method. Calling it through reflections would require half the game to be initialized.
tile.entity = block.newEntity().init(tile, false);
tile.entity.cons = new ConsumeModule();
tile.entity.cons = new ConsumeModule(tile.entity);
if(block.hasItems) tile.entity.items = new ItemModule();
if(block.hasLiquids) tile.entity.liquids = new LiquidModule();
if(block.hasPower){