Gather data
This commit is contained in:
@@ -29,4 +29,35 @@ class SwedishGeneratorTest {
|
||||
assertEquals(0, s.r(1));
|
||||
assertEquals(2, s.c(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStaticSlotMethods() {
|
||||
// Test static r and c extraction
|
||||
// packedRs: 1 at index 0, 2 at index 1
|
||||
long packedRs = (1L << 0) | (2L << 4);
|
||||
assertEquals(1, Slot.r(packedRs, 0));
|
||||
assertEquals(2, Slot.r(packedRs, 1));
|
||||
|
||||
// Test static horiz
|
||||
// dir 2 (right) is horizontal
|
||||
assertTrue(Slot.horiz(2));
|
||||
// dir 3 (down) is vertical
|
||||
assertTrue(!Slot.horiz(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForEachSlot() {
|
||||
SwedishGenerator generator = new SwedishGenerator(3, 3);
|
||||
Grid grid = generator.makeEmptyGrid();
|
||||
grid.setCharAt(0, 0, '2'); // right
|
||||
|
||||
java.util.concurrent.atomic.AtomicInteger count = new java.util.concurrent.atomic.AtomicInteger(0);
|
||||
generator.forEachSlot(grid, (key, rs, cs, len) -> {
|
||||
count.incrementAndGet();
|
||||
assertEquals(2, len);
|
||||
assertEquals(0, Slot.r(rs, 0));
|
||||
assertEquals(1, Slot.c(cs, 0));
|
||||
});
|
||||
assertEquals(1, count.get());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user