introduce bitloops
This commit is contained in:
@@ -33,11 +33,10 @@ public class MainTest {
|
||||
|
||||
@Test
|
||||
void testExtractSlots() {
|
||||
var grid = Grid.createEmpty();
|
||||
|
||||
// Set up digits on the grid to create slots.
|
||||
// CLUE_RIGHT at OFF_0_0 -> slot at (0,1), (0,2)
|
||||
grid.setClue(OFF_0_0, CLUE_RIGHT);
|
||||
var clues = Clues.createEmpty();
|
||||
clues.setClue(OFF_0_0, CLUE_RIGHT);
|
||||
var grid = clues.toGrid();
|
||||
grid.setLetter(OFF_0_1, LETTER_A);
|
||||
grid.setLetter(OFF_0_2, LETTER_B);
|
||||
|
||||
@@ -63,8 +62,9 @@ public class MainTest {
|
||||
|
||||
@Test
|
||||
void testForEachSlot() {
|
||||
var grid = Grid.createEmpty();
|
||||
grid.setClue(OFF_0_0, CLUE_RIGHT); // right
|
||||
var clues = Clues.createEmpty();
|
||||
clues.setClue(OFF_0_0, CLUE_RIGHT);
|
||||
var grid = clues.toGrid();
|
||||
|
||||
var count = new AtomicInteger(0);
|
||||
grid.forEachSlot((key, lo, hi) -> {
|
||||
@@ -84,11 +84,12 @@ public class MainTest {
|
||||
}
|
||||
@Test
|
||||
public void testGridBasics() {
|
||||
var grid = Grid.createEmpty();
|
||||
var clues = Clues.createEmpty();
|
||||
clues.setClue(OFF_1_2, CLUE_UP);
|
||||
var grid = clues.toGrid();
|
||||
|
||||
// Test set/get
|
||||
grid.setLetter(OFF_0_0, LETTER_A);
|
||||
grid.setClue(OFF_1_2, CLUE_UP);
|
||||
grid.setLetter(OFF_2_3, LETTER_Z);
|
||||
|
||||
Assertions.assertEquals(LETTER_A, grid.byteAt(OFF_0_0));
|
||||
@@ -114,28 +115,27 @@ public class MainTest {
|
||||
Assertions.assertTrue(grid.isClue(OFF_1_2)); // digit
|
||||
Assertions.assertTrue(grid.notClue(OFF_1_1)); // '#' is lettercell
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGridDeepCopy() {
|
||||
var grid = Grid.createEmpty();
|
||||
grid.setLetter(Grid.offset(0, 0), (byte) 'A');
|
||||
grid.setLetter(Grid.offset(0, 1), (byte) 'B');
|
||||
grid.setLetter(Grid.offset(1, 0), (byte) 'C');
|
||||
grid.setLetter(Grid.offset(1, 1), (byte) 'D');
|
||||
public void testCluesDeepCopy() {
|
||||
var grid = Clues.createEmpty();
|
||||
grid.setClue(Grid.offset(0, 0), (byte) 1);
|
||||
grid.setClue(Grid.offset(0, 1), (byte) 2);
|
||||
grid.setClue(Grid.offset(1, 0), (byte) 3);
|
||||
grid.setClue(Grid.offset(1, 1), (byte) 0);
|
||||
|
||||
var copy = grid.deepCopyGrid();
|
||||
Assertions.assertEquals((byte) 'A', copy.byteAt(0));
|
||||
Assertions.assertEquals((byte) 1, copy.digitAt(0));
|
||||
|
||||
copy.setLetter(0, (byte) 'X');
|
||||
Assertions.assertEquals((byte) 'X', copy.byteAt(0));
|
||||
Assertions.assertEquals((byte) 'A', grid.byteAt(0)); // Original should be unchanged
|
||||
copy.setClue(0, (byte) 3);
|
||||
Assertions.assertEquals((byte) 3, copy.digitAt(0));
|
||||
Assertions.assertEquals((byte) 1, grid.digitAt(0)); // Original should be unchanged
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMini() {
|
||||
var grid = Grid.createEmpty();
|
||||
val idx = OFF_1_1;
|
||||
grid.setClue(idx, CLUE_LEFT);
|
||||
var clues = Clues.createEmpty();
|
||||
clues.setClue(idx, CLUE_LEFT);
|
||||
var grid = clues.toGrid();
|
||||
Assertions.assertTrue(grid.isClue(idx));
|
||||
}
|
||||
@Test
|
||||
@@ -179,8 +179,8 @@ public class MainTest {
|
||||
Assertions.assertEquals(12348, foundSeed, "Found seed changed");
|
||||
Assertions.assertEquals(18, res.filled().wordCount(), "Number of assigned words changed");
|
||||
Assertions.assertEquals("SLEDE", Lemma.asWord(res.filled().clueMap()[282]));
|
||||
Assertions.assertEquals(74732156493031040L, res.filled().grid().grid().lo);
|
||||
Assertions.assertEquals(193L, res.filled().grid().grid().hi);
|
||||
Assertions.assertEquals(74732156493031040L, res.filled().grid().grid().lo());
|
||||
Assertions.assertEquals(193L, res.filled().grid().grid().hi());
|
||||
}
|
||||
boolean isLetter(byte b) { return (b & 64) != 0; }
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user