Skip to content

Commit 22ca133

Browse files
committed
add test to ensure that simulation is the same as execution and that 1rf fails
1 parent 1636b48 commit 22ca133

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/java/mekanism/common/integration/energy/forgeenergy/EnergyConversionTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,21 @@ void testFEAsJoules() {
210210
assertValueEqual(handler.getEnergy(0), (long) (CONVERSION_RATE * JOULES_CAPACITY) - JOULES_CAPACITY, "stored energy");
211211
}
212212

213+
@Test
214+
@DisplayName("Test wrapping FE to J against a small nearly full container with 1 rf missing")
215+
void testFEAsJoulesNearlyFull() {
216+
//simulates BasicInventorySlot
217+
EnergyStorage feStorage = new EnergyStorage(FE_CAPACITY, FE_CAPACITY, FE_CAPACITY, FE_CAPACITY - 1);
218+
IStrictEnergyHandler handler = new ForgeStrictEnergyHandler(feStorage, getConverter(CONVERSION_RATE));
219+
220+
long storedEnergy = JOULES_CAPACITY;
221+
long simulatedRemainder = handler.insertEnergy(storedEnergy, Action.SIMULATE);
222+
long executedRemainder = handler.insertEnergy(storedEnergy, Action.EXECUTE);
223+
Assertions.assertEquals(simulatedRemainder, executedRemainder, "simulate and execute should be the same");
224+
225+
Assertions.assertEquals(storedEnergy, simulatedRemainder, "expected conversion fail due to floating point remainder");
226+
}
227+
213228
//Validate behavior for when the conversion is the inverse of the default
214229

215230
// WRAPPING STRICT ENERGY TO FORGE ENERGY

0 commit comments

Comments
 (0)