introduce bitloops
This commit is contained in:
@@ -37,12 +37,6 @@ public class MainTest {
|
||||
|
||||
@Test
|
||||
void testStaticSlotMethods() {
|
||||
// Test static offset extraction
|
||||
// packedPos: offset(1, 1) at index 0, offset(2, 2) at index 1
|
||||
var packedPos = ((long) Grid.offset(1, 1)) | (((long) Grid.offset(2, 2)) << 7);
|
||||
assertEquals(Grid.offset(1, 1), Slot.offset(packedPos, 0));
|
||||
assertEquals(Grid.offset(2, 2), Slot.offset(packedPos, 1));
|
||||
|
||||
// Test static horiz
|
||||
// dir 2 (right) is horizontal
|
||||
assertTrue(Slot.horiz(2));
|
||||
@@ -56,21 +50,20 @@ public class MainTest {
|
||||
grid.setClue(0, (byte) '2'); // right
|
||||
|
||||
var count = new AtomicInteger(0);
|
||||
grid.forEachSlot((key, packedPos, len) -> {
|
||||
grid.forEachSlot((key, lo, hi) -> {
|
||||
count.incrementAndGet();
|
||||
assertEquals(8, len);
|
||||
assertEquals(0, Grid.r(Slot.offset(packedPos, 0)));
|
||||
assertEquals(1, Grid.c(Slot.offset(packedPos, 0)));
|
||||
assertEquals(8, Long.bitCount(lo) + Long.bitCount(hi));
|
||||
assertEquals(0, Grid.r(Long.numberOfTrailingZeros(lo)));
|
||||
assertEquals(1, Grid.c(Long.numberOfTrailingZeros(lo)));
|
||||
});
|
||||
assertEquals(1, count.get());
|
||||
}
|
||||
@Test
|
||||
public void testHoriz() {
|
||||
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());
|
||||
assertTrue(Slot.from(2, 0L, 0L).horiz());
|
||||
assertTrue(Slot.from(4, 0L, 0L).horiz());
|
||||
assertFalse(Slot.from(1, 0L, 0L).horiz());
|
||||
assertFalse(Slot.from(3, 0L, 0L).horiz());
|
||||
}
|
||||
@Test
|
||||
public void testGridBasics() {
|
||||
|
||||
Reference in New Issue
Block a user