introduce bitloops
This commit is contained in:
@@ -48,4 +48,46 @@ public class CornerClueTest {
|
||||
assertEquals(1, slots.length);
|
||||
assertEquals(4, Masker.Slot.dir(slots[0].key()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCornerDownLeftSlot() {
|
||||
Clues clues = Clues.createEmpty();
|
||||
// Clue op (0,1), type 5 (Corner Down Left)
|
||||
// Should result in word starting at (0,0) going down.
|
||||
int idx = Masker.offset(0, 1);
|
||||
clues.setClueLo(1L << idx, (byte)5);
|
||||
|
||||
assertEquals(5, clues.getDir(idx));
|
||||
|
||||
// Controleer of forEachSlot het slot vindt
|
||||
final boolean[] found = {false};
|
||||
clues.forEachSlot((key, lo, hi) -> {
|
||||
if (Masker.Slot.dir(key) == 5) {
|
||||
found[0] = true;
|
||||
// Woord zou moeten starten op (0,0)
|
||||
int startIdx = Masker.offset(0, 0);
|
||||
assertTrue((lo & (1L << startIdx)) != 0, "Slot should start at (0,0)");
|
||||
// En omlaag gaan
|
||||
int secondIdx = Masker.offset(1, 0);
|
||||
assertTrue((lo & (1L << secondIdx)) != 0, "Slot should continue to (1,0)");
|
||||
|
||||
// Lengte van het slot zou 8 moeten zijn (van rij 0 t/m 7 in kolom 0)
|
||||
assertEquals(8, Masker.Slot.length(lo, hi));
|
||||
}
|
||||
});
|
||||
assertTrue(found[0], "Corner Down Left slot should be found");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCornerDownLeftExtraction() {
|
||||
Clues clues = Clues.createEmpty();
|
||||
int idx = Masker.offset(0, 1);
|
||||
clues.setClueLo(1L << idx, (byte)5);
|
||||
|
||||
DictEntry[] dict = DictData.DICT.index();
|
||||
Slotinfo[] slots = Masker.slots(clues, dict);
|
||||
|
||||
assertEquals(1, slots.length);
|
||||
assertEquals(5, Masker.Slot.dir(slots[0].key()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user