all
This commit is contained in:
@@ -39,7 +39,7 @@ public class SwedishGeneratorTest {
|
||||
var slot = Slot.from(18 << Slot.BIT_FOR_DIR | (CLUE_RIGHT), 7L, 0L);
|
||||
long pattern = patternForSlot(grid, slot);
|
||||
|
||||
assertEquals(1 | (2 << 5) | (3 << 10), pattern);
|
||||
assertEquals(1L | (28L << 8) | (55L << 16), pattern);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,7 +48,7 @@ public class SwedishGeneratorTest {
|
||||
var slot = Slot.from(1 << Slot.BIT_FOR_DIR | (CLUE_RIGHT), 7L, 0L);
|
||||
long pattern = patternForSlot(grid, slot);
|
||||
|
||||
assertEquals(1 | (0 << 5) | (3 << 10), pattern);
|
||||
assertEquals(1L | (0L << 8) | (55L << 16), pattern);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,7 +57,7 @@ public class SwedishGeneratorTest {
|
||||
var slot = Slot.from(1 << Slot.BIT_FOR_DIR | (CLUE_RIGHT), 7L, 0L);
|
||||
long pattern = patternForSlot(grid, slot);
|
||||
|
||||
assertEquals(0, pattern);
|
||||
assertEquals(0L, pattern);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -66,7 +66,7 @@ public class SwedishGeneratorTest {
|
||||
var slot = Slot.from(1 << Slot.BIT_FOR_DIR | (CLUE_RIGHT), 7L, 0L);
|
||||
long pattern = patternForSlot(grid, slot);
|
||||
|
||||
assertEquals(1, pattern);
|
||||
assertEquals(1L, pattern);
|
||||
}
|
||||
@Test
|
||||
void testRng() {
|
||||
@@ -232,6 +232,18 @@ public class SwedishGeneratorTest {
|
||||
assertEquals(0, count);
|
||||
}
|
||||
|
||||
static long packPattern(String s) {
|
||||
long p = 0;
|
||||
byte[] b = s.getBytes(StandardCharsets.US_ASCII);
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
int val = b[i] & 31;
|
||||
if (val != 0) {
|
||||
p |= (long) (i * 26 + val) << (i << 3);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCandidateInfoForPattern() {
|
||||
var l0 = Lemma.from("IN");
|
||||
@@ -247,7 +259,7 @@ public class SwedishGeneratorTest {
|
||||
|
||||
// Pattern "APP--" for length 5
|
||||
var context = new Context();
|
||||
context.setPattern(Lemma.pack(new byte[]{ 'A', 'P', 'P', DASH, DASH }));
|
||||
context.setPattern(packPattern("APP"));
|
||||
var info = candidateInfoForPattern(context, dict.index()[5], 5);
|
||||
|
||||
assertEquals(2, info.count());
|
||||
@@ -410,14 +422,14 @@ public class SwedishGeneratorTest {
|
||||
var entry5 = dict.index()[5];
|
||||
|
||||
var ctx = new Context();
|
||||
ctx.setPattern(Lemma.pack("APP".getBytes(StandardCharsets.US_ASCII)));
|
||||
assertEquals(2, candidateCountForPattern(ctx, entry5,3));
|
||||
ctx.setPattern(packPattern("APP"));
|
||||
assertEquals(2, candidateCountForPattern(ctx, entry5, 3));
|
||||
|
||||
ctx.setPattern(Lemma.pack("BAN".getBytes(StandardCharsets.US_ASCII)));
|
||||
assertEquals(1, candidateCountForPattern(ctx, entry5,3));
|
||||
ctx.setPattern(packPattern("BAN"));
|
||||
assertEquals(1, candidateCountForPattern(ctx, entry5, 3));
|
||||
|
||||
ctx.setPattern(Lemma.pack("CAT".getBytes(StandardCharsets.US_ASCII)));
|
||||
assertEquals(0, candidateCountForPattern(ctx, entry5,3));
|
||||
ctx.setPattern(packPattern("CAT"));
|
||||
assertEquals(0, candidateCountForPattern(ctx, entry5, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user