Files
purpur-heights/src/test/java/games/dmg/spigotheights/CarryPolicyTest.java
T
dmg a949fd99c4
Release / release (push) Successful in 4m6s
CI / build (push) Successful in 2m7s
feat(heights): mount larger players without consent
2026-09-12 08:35:29 -04:00

29 lines
1.2 KiB
Java

package games.dmg.spigotheights;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class CarryPolicyTest {
@Test
void usesIndependentGapWithDecimalBoundaryTolerance() {
assertTrue(CarryPolicy.eligible(1.0, 0.9, 0.1));
assertTrue(CarryPolicy.eligible(0.5, 0.4, 0.1));
assertFalse(CarryPolicy.eligible(1.0, 0.900001, 0.1));
assertFalse(CarryPolicy.eligible(1.0, 0.9, 0.2));
assertTrue(CarryPolicy.eligible(1.0, 0.8, 0.2));
assertFalse(CarryPolicy.eligible(0.7, 1.0, 0.1));
}
@Test
void zeroGapStillRequiresStrictlyLargerCarrierAndAllInputsMustBeValid() {
assertTrue(CarryPolicy.eligible(1, Math.nextDown(1.0), 0));
assertFalse(CarryPolicy.eligible(1, 1, 0));
assertFalse(CarryPolicy.eligible(0.9, 1, 0));
for (double invalid : new double[] {0, -1, Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY}) {
assertFalse(CarryPolicy.eligible(invalid, 0.4, 0.1));
assertFalse(CarryPolicy.eligible(1, invalid, 0.1));
if (invalid != 0) { assertFalse(CarryPolicy.eligible(1, 0.4, invalid)); }
}
}
}