Gather data

This commit is contained in:
mike
2026-01-08 23:30:59 +01:00
parent 70f3878b32
commit fb99a7aab4
4 changed files with 98 additions and 69 deletions

View File

@@ -47,11 +47,11 @@ public class MainTest {
@Test
void testStaticSlotMethods() {
// Test static r and c extraction
// packedRs: 1 at index 0, 2 at index 1
var packedRs = (1L << 0) | (2L << 4);
assertEquals(1, Slot.r(packedRs, 0));
assertEquals(2, Slot.r(packedRs, 1));
// Test static offset extraction
// packedPos: offset(1, 1) at index 0, offset(2, 2) at index 1
var packedPos = ((long) SwedishGenerator.Grid.offset(1, 1)) | (((long) SwedishGenerator.Grid.offset(2, 2)) << 7);
assertEquals(SwedishGenerator.Grid.offset(1, 1), Slot.offset(packedPos, 0));
assertEquals(SwedishGenerator.Grid.offset(2, 2), Slot.offset(packedPos, 1));
// Test static horiz
// dir 2 (right) is horizontal
@@ -67,21 +67,21 @@ public class MainTest {
grid.setCharAt(0, 0, '2'); // right
var count = new AtomicInteger(0);
generator.forEachSlot(grid, (key, rs, cs, len) -> {
generator.forEachSlot(grid, (key, packedPos, len) -> {
count.incrementAndGet();
assertEquals(8, len);
assertEquals(0, Slot.r(rs, 0));
assertEquals(1, Slot.c(cs, 0));
assertEquals(0, SwedishGenerator.Grid.r(Slot.offset(packedPos, 0)));
assertEquals(1, SwedishGenerator.Grid.c(Slot.offset(packedPos, 0)));
});
assertEquals(1, count.get());
}
@Test
public void testHoriz() {
assertTrue(new Slot(2, 0L, 0L, 1).horiz());
assertTrue(new Slot(4, 0L, 0L, 1).horiz());
assertFalse(new Slot(1, 0L, 3L, 1).horiz());
assertFalse(new Slot(3, 0L, 3L, 1).horiz());
assertFalse(new Slot(5, 0L, 3L, 1).horiz());
assertTrue(Slot.from(2, 0L, 1).horiz());
assertTrue(Slot.from(4, 0L, 1).horiz());
assertFalse(Slot.from(1, 0L, 1).horiz());
assertFalse(Slot.from(3, 0L, 1).horiz());
assertFalse(Slot.from(5, 0L, 1).horiz());
}
@Test
public void testGridBasics() {