mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 09:44:24 +00:00
Integrate lane B
- Merge lane B (sea surface, sea inlets, cave pools, wetness, persisted codes, scheduling knobs) onto lane A - PackHydrologyValidatorTest keeps lane A's loadHydrology helper and lane B's validation tests - Recapture HydrologySettingsTest.DEFAULT_FINGERPRINT and SchemaBuilderIdentityTest.EXPECTED_SCHEMA_DIGEST for the combined settings and schema
This commit is contained in:
commit
2ddc9f1106
171 files changed
+7337
-1896
No files matched your search
@@ -76,7 +76,23 @@ public final class CavePoolProbe {
|
||||
Map<Integer, Integer> chunkSpans, int airLeaks, int openLeaks, int skyLeaks, int foreignFluid, int waterloggableWalls,
|
||||
int unsupportedGravity, int fluidAbove, int gravityCeilings, Map<String, Integer> replaced, List<String> examples) {
|
||||
long failures() {
|
||||
return (long) airLeaks + openLeaks + skyLeaks + foreignFluid + waterloggableWalls + unsupportedGravity + fluidAbove + gravityCeilings;
|
||||
long replacedCells = 0L;
|
||||
for (int cells : replaced.values()) {
|
||||
replacedCells += cells;
|
||||
}
|
||||
return (long) airLeaks + openLeaks + skyLeaks + foreignFluid + waterloggableWalls + unsupportedGravity + fluidAbove + gravityCeilings
|
||||
+ replacedCells;
|
||||
}
|
||||
}
|
||||
|
||||
record Gate(Counts counts, int orderMismatches) {
|
||||
long failures() {
|
||||
return counts.failures() + orderMismatches;
|
||||
}
|
||||
|
||||
String line() {
|
||||
return String.format(Locale.ROOT, "CAVE_POOL_GATE status=%s failures=%d containment_failures=%d order_mismatches=%d",
|
||||
failures() == 0L ? "PASS" : "FAIL", failures(), counts.failures(), orderMismatches);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,14 +101,14 @@ public final class CavePoolProbe {
|
||||
}
|
||||
|
||||
public static void main(String[] arguments) {
|
||||
int exitCode = 1;
|
||||
try {
|
||||
scan(Configuration.parse(arguments));
|
||||
System.exit(0);
|
||||
exitCode = scan(Configuration.parse(arguments)).failures() == 0L ? 0 : 1;
|
||||
} catch (Throwable failure) {
|
||||
System.out.println(LOG_PREFIX + " FAIL");
|
||||
failure.printStackTrace(System.out);
|
||||
System.exit(1);
|
||||
}
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
||||
private static RealPackProbeSupport.Workspace workspace(Configuration configuration) throws Exception {
|
||||
@@ -100,7 +116,7 @@ public final class CavePoolProbe {
|
||||
LOG_PREFIX, null, configuration.work()));
|
||||
}
|
||||
|
||||
private static void scan(Configuration configuration) throws Exception {
|
||||
private static Gate scan(Configuration configuration) throws Exception {
|
||||
try (RealPackProbeSupport.Workspace workspace = workspace(configuration)) {
|
||||
Survey forward;
|
||||
try (RealPackProbeSupport.EngineSession session = workspace.openEngine(configuration.seed(), false, "forward")) {
|
||||
@@ -109,7 +125,8 @@ public final class CavePoolProbe {
|
||||
forward = survey(engine, configuration.area(), null);
|
||||
requireQuiet(engine, "forward");
|
||||
}
|
||||
report(count(forward, configuration.area()));
|
||||
Counts counts = count(forward, configuration.area());
|
||||
report(counts);
|
||||
Map<Long, Long> shuffled;
|
||||
try (RealPackProbeSupport.EngineSession session = workspace.openEngine(configuration.seed(), false, "shuffled")) {
|
||||
Engine engine = session.engine();
|
||||
@@ -117,7 +134,9 @@ public final class CavePoolProbe {
|
||||
shuffled = hashes(engine, configuration);
|
||||
requireQuiet(engine, "shuffled");
|
||||
}
|
||||
compare(forward.hashes(), shuffled);
|
||||
Gate gate = new Gate(counts, compare(forward.hashes(), shuffled));
|
||||
System.out.println(gate.line());
|
||||
return gate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +257,8 @@ public final class CavePoolProbe {
|
||||
}
|
||||
pool.add(new Cell(pack((chunkX << 4) + x, y, (chunkZ << 4) + z), cell.fluidProfileKey()));
|
||||
NativeBlockState state = blocks.get(x, y, z);
|
||||
if (!source(state, cell.fluidProfileKey())) {
|
||||
NativeBlockState expected = engine.getComplex().resolveCaveCellFluid(cell.fluidProfileKey(), (chunkX << 4) + x, (chunkZ << 4) + z);
|
||||
if (!source(state, expected)) {
|
||||
replaced.merge(cell.fluidProfileKey() + "->" + (state == null ? "null" : state.key()), 1, Integer::sum);
|
||||
}
|
||||
});
|
||||
@@ -248,14 +268,13 @@ public final class CavePoolProbe {
|
||||
return guards[0];
|
||||
}
|
||||
|
||||
private static boolean source(NativeBlockState state, String fluid) {
|
||||
static boolean source(NativeBlockState state, NativeBlockState expected) {
|
||||
if (state == null || !state.isFluid()) {
|
||||
return false;
|
||||
}
|
||||
String level = IrisProceduralBlocks.propertyValue(state, "level");
|
||||
boolean still = level == null || "0".equals(level);
|
||||
boolean matches = "lava".equals(fluid) ? state.key().startsWith("minecraft:lava") : state.isWater();
|
||||
return still && matches;
|
||||
return still && IrisProceduralBlocks.materialKey(state).equals(IrisProceduralBlocks.materialKey(expected));
|
||||
}
|
||||
|
||||
private static ChunkRecord record(Hunk<NativeBlockState> blocks, int height) {
|
||||
@@ -338,7 +357,7 @@ public final class CavePoolProbe {
|
||||
}
|
||||
}
|
||||
|
||||
private static void compare(Map<Long, Long> forward, Map<Long, Long> shuffled) {
|
||||
static int compare(Map<Long, Long> forward, Map<Long, Long> shuffled) {
|
||||
int mismatches = 0;
|
||||
List<String> examples = new ArrayList<>();
|
||||
for (Map.Entry<Long, Long> entry : forward.entrySet()) {
|
||||
@@ -355,6 +374,7 @@ public final class CavePoolProbe {
|
||||
}
|
||||
System.out.printf(Locale.ROOT, "CAVE_POOL_ORDER chunks=%d mismatches=%d signature=%016x examples=%s%n", forward.size(), mismatches,
|
||||
signature, examples);
|
||||
return mismatches;
|
||||
}
|
||||
|
||||
static Counts count(Survey survey, Area area) {
|
||||
|
||||
@@ -43,7 +43,7 @@ final class HydrologyReport {
|
||||
boolean passes() {
|
||||
return maxDependencyDepth() == 0 && sum(WindowMetrics::containmentLeaks) == 0 && sum(WindowMetrics::risingWaterSegments) == 0
|
||||
&& sum(WindowMetrics::seamMismatches) == 0 && sum(WindowMetrics::tickConversionCells) == 0
|
||||
&& sum(WindowMetrics::missingSurface) == 0
|
||||
&& sum(WindowMetrics::missingSurface) == 0 && sum(WindowMetrics::bermOverCap) == 0
|
||||
&& sum(WindowMetrics::inletFailures) == 0 && sum(WindowMetrics::cavePoolFailures) == 0 && generationErrors == 0
|
||||
&& failures.isEmpty();
|
||||
}
|
||||
|
||||
@@ -61,21 +61,23 @@ public final class SeaInletProbe {
|
||||
}
|
||||
|
||||
public static void main(String[] arguments) {
|
||||
int exitCode = 1;
|
||||
try {
|
||||
Configuration configuration = Configuration.parse(arguments);
|
||||
long failures = 0L;
|
||||
if (configuration.mode().equals("inventory")) {
|
||||
inventory(configuration);
|
||||
failures = inventory(configuration);
|
||||
} else if (configuration.mode().equals("dump")) {
|
||||
dump(configuration);
|
||||
} else {
|
||||
gate(configuration);
|
||||
failures = gate(configuration).failures();
|
||||
}
|
||||
System.exit(0);
|
||||
exitCode = failures == 0L ? 0 : 1;
|
||||
} catch (Throwable failure) {
|
||||
System.out.println(LOG + " FAIL");
|
||||
failure.printStackTrace(System.out);
|
||||
System.exit(1);
|
||||
}
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
||||
private static void dump(Configuration configuration) throws Exception {
|
||||
@@ -101,7 +103,8 @@ public final class SeaInletProbe {
|
||||
}
|
||||
}
|
||||
|
||||
private static void inventory(Configuration configuration) throws Exception {
|
||||
private static int inventory(Configuration configuration) throws Exception {
|
||||
int failedWindows = 0;
|
||||
try (RealPackProbeSupport.Workspace workspace = workspace(configuration, configuration.packOn());
|
||||
RealPackProbeSupport.EngineSession session = workspace.openEngine(configuration.seed(), false, "inventory")) {
|
||||
HydrologyRuntime runtime = session.engine().getComplex().getHydrologyRuntime();
|
||||
@@ -113,6 +116,7 @@ public final class SeaInletProbe {
|
||||
owned = coast[1] == 0 ? Map.of() : owned(runtime, wx, wx, wz, wz);
|
||||
} catch (RuntimeException failure) {
|
||||
System.out.println("SEA_INLET_WINDOW_FAILED wx=" + wx + " wz=" + wz + " " + rootMessage(failure));
|
||||
failedWindows++;
|
||||
continue;
|
||||
}
|
||||
double length = 0D;
|
||||
@@ -124,6 +128,7 @@ public final class SeaInletProbe {
|
||||
}
|
||||
}
|
||||
}
|
||||
return failedWindows;
|
||||
}
|
||||
|
||||
private static String rootMessage(Throwable failure) {
|
||||
@@ -164,7 +169,7 @@ public final class SeaInletProbe {
|
||||
return new int[]{below, cliff};
|
||||
}
|
||||
|
||||
private static void gate(Configuration configuration) throws Exception {
|
||||
private static Gate gate(Configuration configuration) throws Exception {
|
||||
List<long[]> tiles = tileChunks(configuration);
|
||||
Run forward = run(configuration, configuration.packOn(), tiles, null, false, true, 1, "on-forward");
|
||||
List<long[]> all = new ArrayList<>(forward.order);
|
||||
@@ -175,7 +180,7 @@ public final class SeaInletProbe {
|
||||
System.out.println(LOG + " scan chunks " + forward.scanChunks.size() + ", generated chunks " + all.size());
|
||||
Run reverse = run(configuration, configuration.packOn(), all, null, true, false, configuration.threads(), "on-reverse");
|
||||
Run baseline = run(configuration, configuration.packOff(), scanned, forward.scanChunks, false, false, configuration.threads(), "off");
|
||||
report(configuration, forward.inlets, forward, reverse, baseline);
|
||||
return report(configuration, forward.inlets, forward, reverse, baseline);
|
||||
}
|
||||
|
||||
private static Run run(Configuration configuration, File pack, List<long[]> chunks, Set<Long> scanChunks, boolean reverse, boolean inventory,
|
||||
@@ -256,7 +261,19 @@ public final class SeaInletProbe {
|
||||
static final Checks NONE = new Checks(0, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, List.of());
|
||||
|
||||
long failures() {
|
||||
return leaks + missingWater + waterAbove + roofViolations + openRoofViolations + disconnected + shellOpen + shellLoose;
|
||||
return leaks + missingWater + waterAbove + roofViolations + roofBreaches + openRoofViolations + disconnected + shellOpen + shellLoose;
|
||||
}
|
||||
}
|
||||
|
||||
record Gate(Checks checks, int orderMismatches, int inletsWithOtherLevel, int addedLeaks) {
|
||||
long failures() {
|
||||
return checks.failures() + orderMismatches + inletsWithOtherLevel + addedLeaks;
|
||||
}
|
||||
|
||||
String line() {
|
||||
return String.format(Locale.ROOT, "SEA_INLET_GATE status=%s failures=%d checkFailures=%d orderMismatches=%d inletsWithOtherLevel=%d"
|
||||
+ " addedLeaks=%d", failures() == 0L ? "PASS" : "FAIL", failures(), checks.failures(), orderMismatches,
|
||||
inletsWithOtherLevel, addedLeaks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,8 +312,12 @@ public final class SeaInletProbe {
|
||||
}
|
||||
Scan scan = new Scan(run, run.sea, run.roofClearance, inlets);
|
||||
scan.run();
|
||||
return checks(scan);
|
||||
}
|
||||
|
||||
private static Checks checks(Scan scan) {
|
||||
Scan.InletStats total = scan.total;
|
||||
return new Checks(inlets.size(), total.leaks, total.missingWater, total.waterAbove, total.roofViolations, total.roofBreaches,
|
||||
return new Checks(scan.inlets.size(), total.leaks, total.missingWater, total.waterAbove, total.roofViolations, total.roofBreaches,
|
||||
total.openRoofViolations, total.disconnected, scan.shellOpen, scan.shellLoose, total.looseBeds, List.copyOf(scan.examples));
|
||||
}
|
||||
|
||||
@@ -363,7 +384,7 @@ public final class SeaInletProbe {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
private static void report(Configuration configuration, Map<Long, SeaInlet> touching, Run on, Run reverse, Run off) {
|
||||
private static Gate report(Configuration configuration, Map<Long, SeaInlet> touching, Run on, Run reverse, Run off) {
|
||||
int sea = on.sea;
|
||||
int clearance = on.roofClearance;
|
||||
List<SeaInlet> owned = new ArrayList<>();
|
||||
@@ -374,8 +395,9 @@ public final class SeaInletProbe {
|
||||
}
|
||||
Scan scan = new Scan(on, sea, clearance, owned);
|
||||
scan.run();
|
||||
int onLeaks = scan.countAllLeaks();
|
||||
int offLeaks = new Scan(off, sea, clearance, owned).countAllLeaks();
|
||||
Set<Long> onLeaks = scan.allLeaks();
|
||||
Set<Long> offLeaks = new Scan(off, sea, clearance, owned).allLeaks();
|
||||
int addedLeaks = addedLeaks(onLeaks, offLeaks);
|
||||
int mismatches = mismatches(on.hashes, reverse.hashes);
|
||||
|
||||
System.out.println("SEA_INLET_INVENTORY owned=" + owned.size() + " touching=" + touching.size());
|
||||
@@ -403,7 +425,8 @@ public final class SeaInletProbe {
|
||||
scan.total.missingWater, scan.total.seaPlants, scan.total.seaLayers, scan.total.decorations, scan.total.nonSource,
|
||||
scan.total.waterAbove, scan.total.wet, scan.total.dry);
|
||||
System.out.printf(Locale.ROOT, "SEA_INLET_LEVEL sea=%d inletsWithOtherLevel=%d%n", sea, offLevel);
|
||||
System.out.printf(Locale.ROOT, "SEA_INLET_ALL_WATER_LEAKS scanChunks=%d inletsOn=%d inletsOff=%d%n", on.bands.size(), onLeaks, offLeaks);
|
||||
System.out.printf(Locale.ROOT, "SEA_INLET_ALL_WATER_LEAKS scanChunks=%d inletsOn=%d inletsOff=%d added=%d%n", on.bands.size(),
|
||||
onLeaks.size(), offLeaks.size(), addedLeaks);
|
||||
System.out.printf(Locale.ROOT, "SEA_INLET_ROOF min=%d violations=%d breaches=%d openRoofViolations=%d coveredColumns=%d openColumns=%d%n",
|
||||
scan.total.roofMin, scan.total.roofViolations, scan.total.roofBreaches, scan.total.openRoofViolations, scan.total.covered,
|
||||
scan.total.open);
|
||||
@@ -413,6 +436,9 @@ public final class SeaInletProbe {
|
||||
scan.shellOpen, scan.shellLoose, maxOpenLandStations(owned), scan.total.looseBeds);
|
||||
System.out.printf(Locale.ROOT, "SEA_INLET_DETERMINISM chunks=%d reverseChunks=%d mismatches=%d crossChunkInlets=%d crossWindowInlets=%d%n",
|
||||
on.hashes.size(), reverse.hashes.size(), mismatches, scan.crossChunk(), scan.crossWindow());
|
||||
Gate gate = new Gate(checks(scan), mismatches, offLevel, addedLeaks);
|
||||
System.out.println(gate.line());
|
||||
return gate;
|
||||
}
|
||||
|
||||
private static int openStations(SeaInlet inlet) {
|
||||
@@ -485,6 +511,18 @@ public final class SeaInletProbe {
|
||||
return (int) key;
|
||||
}
|
||||
|
||||
static int addedLeaks(Set<Long> on, Set<Long> off) {
|
||||
int added = 0;
|
||||
for (long leak : on) {
|
||||
added += off.contains(leak) ? 0 : 1;
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
static long cellKey(int x, int y, int z) {
|
||||
return ((long) x & 0x3FFFFFFL) << 38 | ((long) z & 0x3FFFFFFL) << 12 | (y & 0xFFFL);
|
||||
}
|
||||
|
||||
static byte classify(NativeBlockState state, String seaFluid) {
|
||||
if (state == null || state.isAir()) {
|
||||
return AIR;
|
||||
@@ -963,8 +1001,8 @@ public final class SeaInletProbe {
|
||||
return level >= 0 && level < band.levels && seen[((z & 15) << 4 | (x & 15)) * band.levels + level];
|
||||
}
|
||||
|
||||
private int countAllLeaks() {
|
||||
int leaks = 0;
|
||||
private Set<Long> allLeaks() {
|
||||
Set<Long> leaks = new HashSet<>();
|
||||
for (Band band : run.bands.values()) {
|
||||
for (int lz = 0; lz < 16; lz++) {
|
||||
for (int lx = 0; lx < 16; lx++) {
|
||||
@@ -984,7 +1022,7 @@ public final class SeaInletProbe {
|
||||
byte below = band.at(lx, y - 1, lz);
|
||||
open |= below == AIR || below == OTHER;
|
||||
if (open) {
|
||||
leaks++;
|
||||
leaks.add(cellKey(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class CavePoolChecksTest {
|
||||
@Test
|
||||
@@ -16,9 +21,59 @@ public class CavePoolChecksTest {
|
||||
assertEquals(0L, counts(0, 0, 0, 0, 0, 0, 0, 0).failures());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theGateFailsOnContainmentAndOrderMismatches() {
|
||||
CavePoolProbe.Gate passing = new CavePoolProbe.Gate(counts(0, 0, 0, 0, 0, 0, 0, 0), 0);
|
||||
assertEquals(0L, passing.failures());
|
||||
assertTrue(passing.line(), passing.line().startsWith("CAVE_POOL_GATE status=PASS failures=0 "));
|
||||
assertEquals(2L, new CavePoolProbe.Gate(counts(0, 0, 0, 0, 0, 0, 0, 0), 2).failures());
|
||||
CavePoolProbe.Gate failing = new CavePoolProbe.Gate(counts(1, 2, 3, 4, 5, 6, 7, 8), 1);
|
||||
assertEquals(37L, failing.failures());
|
||||
assertTrue(failing.line(), failing.line().startsWith("CAVE_POOL_GATE status=FAIL failures=37 "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void poolCellsThatDidNotStayStillSourcesOfTheirFluidFail() {
|
||||
CavePoolProbe.Counts replaced = new CavePoolProbe.Counts(1, 1, 1, 1, Map.of(), List.of(), List.of(), Map.of(), 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
Map.of("water->minecraft:stone", 2, "lava->null", 1), List.of());
|
||||
assertEquals(3L, replaced.failures());
|
||||
assertEquals(3L, new CavePoolProbe.Gate(replaced, 0).failures());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void poolSourcesMatchTheFluidTheCellResolvesTo() {
|
||||
NativeBlockState water = fluid("minecraft:water", true);
|
||||
NativeBlockState lava = fluid("minecraft:lava", false);
|
||||
assertTrue(CavePoolProbe.source(fluid("minecraft:water", true), water));
|
||||
assertTrue(CavePoolProbe.source(fluid("minecraft:water[level=0]", true), water));
|
||||
assertFalse("flowing water is not a pool source", CavePoolProbe.source(fluid("minecraft:water[level=1]", true), water));
|
||||
assertFalse("lava is not a water pool source", CavePoolProbe.source(fluid("minecraft:lava", false), water));
|
||||
assertTrue(CavePoolProbe.source(fluid("minecraft:lava[level=0]", false), lava));
|
||||
assertFalse(CavePoolProbe.source(fluid("minecraft:water", true), lava));
|
||||
assertFalse(CavePoolProbe.source(null, water));
|
||||
NativeBlockState stone = mock(NativeBlockState.class);
|
||||
when(stone.key()).thenReturn("minecraft:stone");
|
||||
assertFalse(CavePoolProbe.source(stone, water));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void orderMismatchesCountChunksWhoseHashesDiffer() {
|
||||
assertEquals(0, CavePoolProbe.compare(Map.of(1L, 10L, 2L, 20L), Map.of(2L, 20L, 1L, 10L)));
|
||||
assertEquals(1, CavePoolProbe.compare(Map.of(1L, 10L, 2L, 20L), Map.of(1L, 10L, 2L, 21L)));
|
||||
assertEquals("a chunk missing from the shuffled run is a mismatch", 1, CavePoolProbe.compare(Map.of(1L, 10L, 2L, 20L), Map.of(1L, 10L)));
|
||||
}
|
||||
|
||||
private static CavePoolProbe.Counts counts(int air, int open, int sky, int foreign, int waterlogged, int gravity, int fluidAbove,
|
||||
int gravityCeilings) {
|
||||
return new CavePoolProbe.Counts(1, 1, 1, 1, Map.of(), List.of(), List.of(), Map.of(), air, open, sky, foreign, waterlogged, gravity,
|
||||
fluidAbove, gravityCeilings, Map.of(), List.of());
|
||||
}
|
||||
|
||||
private static NativeBlockState fluid(String key, boolean water) {
|
||||
NativeBlockState state = mock(NativeBlockState.class);
|
||||
when(state.key()).thenReturn(key);
|
||||
when(state.isFluid()).thenReturn(true);
|
||||
when(state.isWater()).thenReturn(water);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,11 @@ import org.junit.Test;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -188,6 +190,24 @@ public class HydrologyProbeTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bermOverCapFailsTheProbe() {
|
||||
HydrologyReport.Result clean = result(0L);
|
||||
assertTrue(clean.lines().toString(), clean.passes());
|
||||
HydrologyReport.Result raised = result(3L);
|
||||
assertFalse(raised.passes());
|
||||
Map<String, String> total = fields(line(raised.lines(), "IRIS_HYDROLOGY_TOTAL"));
|
||||
assertEquals("3", total.get("bermOverCap"));
|
||||
assertEquals("FAIL", total.get("status"));
|
||||
assertTrue(total.get("missedTargets"), total.get("missedTargets").contains("bermOverCap"));
|
||||
}
|
||||
|
||||
private static HydrologyReport.Result result(long bermOverCap) {
|
||||
HydrologyReport.WindowMetrics window = new HydrologyReport.WindowMetrics(new WindowKey(4, 4), 1D, 0L, 0L, 1D, 1D, 0, 1D, 1, 1D, 1,
|
||||
Set.of(64), 0, 0L, 0L, 0L, 0L, 0L, bermOverCap, 0, 0L, 0, 0L, 1L, "digest");
|
||||
return new HydrologyReport.Result(List.of(window), 1D, 1, 1, 0L, 0L, 1D, 0L, "digest", List.of(), List.of());
|
||||
}
|
||||
|
||||
private static int[] bankBesideWater(SyntheticHydrology fixture) {
|
||||
int[][] offsets = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||
int min = LAND.minX() * HydrologyWindows.CHUNKS;
|
||||
|
||||
@@ -4,19 +4,56 @@ import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class SeaInletChecksTest {
|
||||
@Test
|
||||
public void roofBreachesAndLooseBedsAreReportedButOnlyContainmentAndSealChecksFail() {
|
||||
SeaInletProbe.Checks reported = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 1939L, 0L, 0L, 0L, 0L, 952L, List.of());
|
||||
public void roofBreachesFailWithTheContainmentSealAndRoofChecks() {
|
||||
SeaInletProbe.Checks breached = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 1939L, 0L, 0L, 0L, 0L, 0L, List.of());
|
||||
assertEquals(1939L, breached.failures());
|
||||
SeaInletProbe.Checks failing = new SeaInletProbe.Checks(3, 1L, 2L, 3L, 4L, 9L, 5L, 6L, 7L, 8L, 0L, List.of());
|
||||
assertEquals(45L, failing.failures());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void looseBedsAreReportedButDoNotFail() {
|
||||
SeaInletProbe.Checks reported = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 952L, List.of());
|
||||
assertEquals(0L, reported.failures());
|
||||
SeaInletProbe.Checks failing = new SeaInletProbe.Checks(3, 1L, 2L, 3L, 4L, 0L, 5L, 6L, 7L, 8L, 0L, List.of());
|
||||
assertEquals(36L, failing.failures());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theGateFailsOnEveryCheckIncludingOrderSeaLevelAndAddedLeaks() {
|
||||
SeaInletProbe.Checks clean = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 952L, List.of());
|
||||
SeaInletProbe.Gate passing = new SeaInletProbe.Gate(clean, 0, 0, 0);
|
||||
assertEquals(0L, passing.failures());
|
||||
assertTrue(passing.line(), passing.line().startsWith("SEA_INLET_GATE status=PASS failures=0 "));
|
||||
assertEquals(2L, new SeaInletProbe.Gate(clean, 0, 0, 2).failures());
|
||||
assertEquals(1L, new SeaInletProbe.Gate(clean, 1, 0, 0).failures());
|
||||
assertEquals(1L, new SeaInletProbe.Gate(clean, 0, 1, 0).failures());
|
||||
SeaInletProbe.Checks breached = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 4L, 0L, 0L, 0L, 0L, 0L, List.of());
|
||||
SeaInletProbe.Gate failing = new SeaInletProbe.Gate(breached, 0, 0, 0);
|
||||
assertEquals(4L, failing.failures());
|
||||
assertTrue(failing.line(), failing.line().startsWith("SEA_INLET_GATE status=FAIL failures=4 "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addedLeaksAreTheLeaksMissingWithoutInlets() {
|
||||
long kept = SeaInletProbe.cellKey(10, 300, -20);
|
||||
long removed = SeaInletProbe.cellKey(11, 300, -20);
|
||||
long added = SeaInletProbe.cellKey(10, 301, -20);
|
||||
assertEquals(0, SeaInletProbe.addedLeaks(Set.of(kept), Set.of(kept)));
|
||||
assertEquals("inlets that remove natural leaks do not fail", 0, SeaInletProbe.addedLeaks(Set.of(kept), Set.of(kept, removed)));
|
||||
assertEquals("a leak the inlets move counts although the totals match", 1, SeaInletProbe.addedLeaks(Set.of(kept, added),
|
||||
Set.of(kept, removed)));
|
||||
assertEquals(2, SeaInletProbe.addedLeaks(Set.of(added, removed), Set.of()));
|
||||
assertNotEquals(SeaInletProbe.cellKey(-1, 300, 0), SeaInletProbe.cellKey(0, 300, -1));
|
||||
assertNotEquals(SeaInletProbe.cellKey(5, 0, 5), SeaInletProbe.cellKey(5, 4095, 5));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user