Gather data
This commit is contained in:
@@ -14,6 +14,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static puzzle.Main.indentLines;
|
||||
import static puzzle.SwedishGenerator.C_DASH;
|
||||
import static puzzle.SwedishGenerator.DASH;
|
||||
|
||||
public class MainTest {
|
||||
|
||||
@@ -101,7 +102,7 @@ public class MainTest {
|
||||
Assertions.assertEquals('A', grid.getCharAt(0, 0));
|
||||
Assertions.assertEquals('5', grid.getCharAt(1, 2));
|
||||
Assertions.assertEquals('Z', grid.getCharAt(2, 3));
|
||||
Assertions.assertEquals(C_DASH, grid.getCharAt(1, 1));
|
||||
Assertions.assertEquals(DASH, grid.byteAt(1, 1));
|
||||
|
||||
// Test isLetterAt
|
||||
Assertions.assertTrue(grid.isLetterAt(0, 0));
|
||||
@@ -185,29 +186,20 @@ public class MainTest {
|
||||
Assertions.assertEquals(12347, foundSeed, "Found seed changed");
|
||||
Assertions.assertEquals(20, res.filled().clueMap().size(), "Number of assigned words changed");
|
||||
Assertions.assertEquals(763.8, res.filled().simplicity(), 1e-9, "Simplicity value changed");
|
||||
Assertions.assertArrayEquals(new char[]{ 'M', 'A', 'N', 'T', 'A' }, res.filled().clueMap().get(1377).word());
|
||||
Assertions.assertArrayEquals(new byte[]{ 'M', 'A', 'N', 'T', 'A' }, res.filled().clueMap().get(1377).word());
|
||||
}
|
||||
@Test
|
||||
public void testIsLetterA() {
|
||||
SwedishGenerator generator = new SwedishGenerator();
|
||||
assertTrue(generator.isLetter('A'));
|
||||
assertTrue(SwedishGenerator.isLetter((byte) 'A'));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsLetterZ() {
|
||||
SwedishGenerator generator = new SwedishGenerator();
|
||||
assertTrue(generator.isLetter('Z'));
|
||||
assertTrue(SwedishGenerator.isLetter((byte) 'Z'));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNotLetterLowercaseA() {
|
||||
SwedishGenerator generator = new SwedishGenerator();
|
||||
assertFalse(generator.isLetter('a'));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNotLetterSymbol() {
|
||||
SwedishGenerator generator = new SwedishGenerator();
|
||||
assertFalse(generator.isLetter('@'));
|
||||
assertFalse(SwedishGenerator.isLetter((byte) 'a'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@ package puzzle;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import puzzle.SwedishGenerator.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -16,40 +13,40 @@ public class SwedishGeneratorTest {
|
||||
void testPatternForSlotAllLetters() {
|
||||
var grid = new Grid(new byte[]{ 65, 66, 67 }); // A B C
|
||||
var slot = Slot.from(0 << 8 | 1 << 4 | 2, ((long) 0) | ((long) 1 << 7) | ((long) 2 << 14), 3);
|
||||
var pattern = new char[3];
|
||||
var pattern = new byte[3];
|
||||
SwedishGenerator.patternForSlot(grid, slot, pattern);
|
||||
|
||||
assertArrayEquals(new char[]{ 'A', 'B', 'C' }, pattern);
|
||||
assertArrayEquals(new byte[]{ 'A', 'B', 'C' }, pattern);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPatternForSlotMixed() {
|
||||
var grid = new Grid(new byte[]{ 65, (byte) ('0' + 1), 67 }); // A - C
|
||||
var slot = Slot.from(0 << 8 | 1 << 4 | 2, ((long) 0) | ((long) 1 << 7) | ((long) 2 << 14), 3);
|
||||
var pattern = new char[3];
|
||||
var pattern = new byte[3];
|
||||
SwedishGenerator.patternForSlot(grid, slot, pattern);
|
||||
|
||||
assertArrayEquals(new char[]{ 'A', SwedishGenerator.C_DASH, 'C' }, pattern);
|
||||
assertArrayEquals(new byte[]{ 'A', SwedishGenerator.DASH, 'C' }, pattern);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPatternForSlotAllDashes() {
|
||||
var grid = new Grid(new byte[]{ (byte) ('0' + 1), (byte) ('0' + 1), (byte) ('0' + 1) }); // - - -
|
||||
var slot = Slot.from(0 << 8 | 1 << 4 | 2, ((long) 0) | ((long) 1 << 7) | ((long) 2 << 14), 3);
|
||||
var pattern = new char[3];
|
||||
var pattern = new byte[3];
|
||||
SwedishGenerator.patternForSlot(grid, slot, pattern);
|
||||
|
||||
assertArrayEquals(new char[]{ SwedishGenerator.C_DASH, SwedishGenerator.C_DASH, SwedishGenerator.C_DASH }, pattern);
|
||||
assertArrayEquals(new byte[]{ SwedishGenerator.DASH, SwedishGenerator.DASH, SwedishGenerator.DASH }, pattern);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPatternForSlotSingleLetter() {
|
||||
var grid = new Grid(new byte[]{ 65, (byte) ('0' + 1), (byte) ('0' + 1) }); // A - -
|
||||
var slot = Slot.from(0 << 8 | 1 << 4 | 2, ((long) 0) | ((long) 1 << 7) | ((long) 2 << 14), 3);
|
||||
var pattern = new char[3];
|
||||
var pattern = new byte[3];
|
||||
SwedishGenerator.patternForSlot(grid, slot, pattern);
|
||||
|
||||
assertArrayEquals(new char[]{ 'A', SwedishGenerator.C_DASH, SwedishGenerator.C_DASH }, pattern);
|
||||
assertArrayEquals(new byte[]{ 'A', SwedishGenerator.DASH, SwedishGenerator.DASH }, pattern);
|
||||
}
|
||||
@Test
|
||||
void testRng() {
|
||||
@@ -106,10 +103,10 @@ public class SwedishGeneratorTest {
|
||||
@Test
|
||||
void testLemmaAndDict() {
|
||||
var l1 = new Lemma("APPLE", 5, "A fruit");
|
||||
Assertions.assertArrayEquals("APPLE".toCharArray(), l1.word());
|
||||
Assertions.assertArrayEquals("APPLE".getBytes(), l1.word());
|
||||
assertEquals(5, l1.word().length);
|
||||
assertEquals(5, l1.simpel());
|
||||
assertEquals('A', l1.charAt(0));
|
||||
assertEquals('A', l1.byteAt(0));
|
||||
|
||||
var l2 = new Lemma("AXE", 2, "A tool");
|
||||
var dict = new Dict(new Lemma[]{ l1, l2 });
|
||||
@@ -119,7 +116,7 @@ public class SwedishGeneratorTest {
|
||||
|
||||
var entry3 = dict.index()[3];
|
||||
assertEquals(1, entry3.words().size());
|
||||
Assertions.assertArrayEquals("AXE".toCharArray(), entry3.words().getFirst().word());
|
||||
Assertions.assertArrayEquals("AXE".getBytes(), entry3.words().getFirst().word());
|
||||
|
||||
// Check pos indexing
|
||||
// AXE: A at 0, X at 1, E at 2
|
||||
@@ -181,7 +178,7 @@ public class SwedishGeneratorTest {
|
||||
|
||||
// Pattern "APP--" for length 5
|
||||
var context = new Context();
|
||||
context.setPatter(new char[]{ 'A', 'P', 'P', SwedishGenerator.C_DASH, SwedishGenerator.C_DASH });
|
||||
context.setPatter(new byte[]{ 'A', 'P', 'P', SwedishGenerator.DASH, SwedishGenerator.DASH });
|
||||
var info = gen.candidateInfoForPattern(context, dict.index()[5], 5);
|
||||
|
||||
assertEquals(2, info.count());
|
||||
|
||||
Reference in New Issue
Block a user