introduce bitloops
This commit is contained in:
@@ -13,13 +13,12 @@ import puzzle.Masker.Slot;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static precomp.Const9x8.*;
|
||||
import static precomp.Const9x8.Cell.r0c0d1;
|
||||
import static puzzle.SwedishGenerator.*;
|
||||
import static puzzle.SwedishGeneratorTest.Idx.IDX_0_0;
|
||||
|
||||
public class SwedishGeneratorTest {
|
||||
|
||||
public static final char C_DASH = '\0';
|
||||
public static final byte DASH = (byte) C_DASH;
|
||||
static Grid createEmpty() { return new Grid(new byte[SIZE], X, X); }
|
||||
record Context(long[] bitset) {
|
||||
|
||||
@@ -137,8 +136,8 @@ public class SwedishGeneratorTest {
|
||||
@Test
|
||||
void testPatternForSlotMixed() {
|
||||
var grid = createEmpty();
|
||||
GridBuilder.placeWord(grid, grid.g, Slot.packSlotKey(0, CLUE_RIGHT), 1L << OFF_0_0, 0, Lemma.from("A"));
|
||||
GridBuilder.placeWord(grid, grid.g, Slot.packSlotKey(0, CLUE_RIGHT), 1L << OFF_2_0, 0, Lemma.from("C"));
|
||||
GridBuilder.placeWord(grid, grid.g, r0c0d1.slotKey, 1L << OFF_0_0, 0, Lemma.from("A"));
|
||||
GridBuilder.placeWord(grid, grid.g, r0c0d1.slotKey, 1L << OFF_2_0, 0, Lemma.from("C"));
|
||||
var key = Slot.packSlotKey(OFF_1_0, CLUE_RIGHT);
|
||||
var pattern = patternForSlot(grid.lo, grid.hi, grid.g, key, 7L, 0L);
|
||||
assertEquals(14081L, pattern);
|
||||
@@ -155,7 +154,8 @@ public class SwedishGeneratorTest {
|
||||
@Test
|
||||
void testPatternForSlotSingleLetter() {
|
||||
var grid = createEmpty();
|
||||
GridBuilder.placeWord(grid, grid.g, Slot.packSlotKey(0, CLUE_RIGHT), 1L << OFF_0_0, 0, Lemma.from("A"));
|
||||
//Slot.packSlotKey(0, CLUE_RIGHT)
|
||||
GridBuilder.placeWord(grid, grid.g, r0c0d1.slotKey, 1L << OFF_0_0, 0, Lemma.from("A"));
|
||||
var key = Slot.packSlotKey(1, CLUE_RIGHT);
|
||||
var pattern = patternForSlot(grid.lo, grid.hi, grid.g, key, 7L, 0L);
|
||||
assertEquals(1L, pattern);
|
||||
@@ -189,7 +189,7 @@ public class SwedishGeneratorTest {
|
||||
void testGrid() {
|
||||
var empty = Clues.createEmpty();
|
||||
var grid = new Gridded(empty);
|
||||
GridBuilder.placeWord(grid.grid(), grid.grid().g, Slot.packSlotKey(0, CLUE_RIGHT), 1L << OFF_0_0, 0, Lemma.from("A"));
|
||||
GridBuilder.placeWord(grid.grid(), grid.grid().g, r0c0d1.slotKey, 1L << OFF_0_0, 0, Lemma.from("A"));
|
||||
val arr = grid.stream(empty).collect(Collectors.toMap(LetterAt::index, LetterAt::letter));
|
||||
assertEquals(1, arr.size());
|
||||
assertEquals(LETTER_A, arr.get(OFF_0_0));
|
||||
@@ -393,8 +393,8 @@ public class SwedishGeneratorTest {
|
||||
grid.grid().lo = low;
|
||||
map = grid.stream(Masker.Clues.createEmpty()).collect(Collectors.toMap(LetterAt::index, LetterAt::letter));
|
||||
assertEquals(0, map.size());
|
||||
assertEquals(DASH, map.getOrDefault(OFF_0_1, DASH));
|
||||
assertEquals(DASH, map.getOrDefault(OFF_0_2, DASH));
|
||||
assertFalse(map.containsKey(OFF_0_1));
|
||||
assertFalse(map.containsKey(OFF_0_2));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user