Search in sources :

Example 6 with CSVStore

use of helper.CSVStore in project solution-finder by knewjade.

the class PathCSVCaseTest method solution1WithoutHold.

@Test
void solution1WithoutHold() throws Exception {
    String fumen = "v115@9gF8DeG8CeH8BeG8MeAgH";
    String command = String.format("path -t %s -p *p3 -f csv -k solution -H no", fumen);
    System.out.println(command);
    Log log = RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    assertThat(log.getReturnCode()).isEqualTo(0);
    assertThat(log.getOutput()).contains(Messages.foundPath(18));
    // column: [fumen, use, num-solutions, num-patterns, solutions, patterns]
    CSVStore csvStore = OutputFileHelper.loadPathSolutionCSV();
    assertThat(csvStore.size()).isEqualTo(18);
    assertThat(csvStore.row("fumen", "http://fumen.zui.jp/?v115@9gF8BthlG8ywH8wwglG8BtglJeAgWDA0iDCA")).contains(entry("use", "TLZ")).contains(entry("num-solutions", "1")).contains(entry("num-patterns", "1")).contains(entry("solutions", "TLZ")).contains(entry("patterns", "TLZ"));
    assertThat(csvStore.row("fumen", "http://fumen.zui.jp/?v115@9gF8zhG8RpwwH8xwG8RpwwJeAgWDAUXdBA")).contains(entry("use", "TIO")).contains(entry("num-solutions", "3")).contains(entry("num-patterns", "3")).matches(map -> count(map.get("solutions"), 3), "fail solutions").matches(map -> count(map.get("patterns"), 3), "fail patterns");
    assertThat(csvStore.row("fumen", "http://fumen.zui.jp/?v115@9gF8zhG8ywH8wwglG8ilJeAgWDAsedBA")).contains(entry("use", "TIL")).contains(entry("num-solutions", "6")).contains(entry("num-patterns", "6")).matches(map -> count(map.get("solutions"), 6), "fail solutions").matches(map -> count(map.get("patterns"), 6), "fail patterns");
}
Also used : SimpleOperation(common.datastore.SimpleOperation) CSVStore(helper.CSVStore) BeforeEach(org.junit.jupiter.api.BeforeEach) Piece(core.mino.Piece) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IOException(java.io.IOException) Rotate(core.srs.Rotate) EntryPointMain(entry.EntryPointMain) Assertions.entry(org.assertj.core.api.Assertions.entry) Test(org.junit.jupiter.api.Test) Operations(common.datastore.Operations) Field(core.field.Field) _usecase(_usecase) Operation(common.datastore.Operation) FieldFactory(core.field.FieldFactory) Mino(core.mino.Mino) CSVStore(helper.CSVStore) Test(org.junit.jupiter.api.Test)

Example 7 with CSVStore

use of helper.CSVStore in project solution-finder by knewjade.

the class PathCSVCaseTest method pattern1WithoutHold.

@Test
void pattern1WithoutHold() throws Exception {
    String fumen = "v115@9gF8DeG8CeH8BeG8MeAgH";
    String command = String.format("path -t %s -p *p4 -f csv -k pattern -H no", fumen);
    Log log = RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    assertThat(log.getReturnCode()).isEqualTo(0);
    assertThat(log.getOutput()).contains(Messages.foundPath(18)).contains(Messages.success(144, 840));
    // column: [pattern, num-solutions, use, nouse, fumens]
    CSVStore csvStore = OutputFileHelper.loadPathPatternCSV();
    assertThat(csvStore.size()).isEqualTo(840);
    assertThat(csvStore.row("pattern", "OSJ")).contains(entry("num-solutions", "0")).contains(entry("use", "")).contains(entry("nouse", "")).contains(entry("fumens", ""));
    assertThat(csvStore.row("pattern", "JIT")).contains(entry("num-solutions", "1")).contains(entry("use", "TIJ")).contains(entry("nouse", "")).contains(entry("fumens", "v115@9gF8ywwhG8wwg0whH8g0whG8h0whJeAgWDAK+1BA"));
    assertThat(csvStore.row("pattern", "TLZ")).contains(entry("num-solutions", "2")).contains(entry("use", "TLZ")).contains(entry("nouse", "")).matches(map -> count(map.get("fumens"), 2), "fail fumens");
}
Also used : CSVStore(helper.CSVStore) Test(org.junit.jupiter.api.Test)

Example 8 with CSVStore

use of helper.CSVStore in project solution-finder by knewjade.

the class PathCSVCaseTest method pattern2.

@Test
void pattern2() throws Exception {
    // reservedオプション
    String fumen = "v115@9gE8DewhF8CewhG8BewhF8CewhJeAgH";
    String command = String.format("path -t %s -p I,*p4 -f csv -k pattern -r yes", fumen);
    Log log = RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    assertThat(log.getReturnCode()).isEqualTo(0);
    assertThat(log.getOutput()).contains(Messages.foundPath(18)).contains(Messages.success(514, 840));
    // column: [pattern, num-solutions, use, nouse, fumens]
    CSVStore csvStore = OutputFileHelper.loadPathPatternCSV();
    assertThat(csvStore.size()).isEqualTo(840);
    assertThat(csvStore.row("pattern", "ISZJO")).contains(entry("num-solutions", "0")).contains(entry("use", "")).contains(entry("nouse", "")).contains(entry("fumens", ""));
    assertThat(csvStore.row("pattern", "ILZJT")).contains(entry("num-solutions", "1")).contains(entry("use", "TILZ")).contains(entry("nouse", "J")).contains(entry("fumens", "v115@9gE8ywAtwhF8wwBtwhG8AtglwhF8ilwhJeAgWEAMej?xC"));
    assertThat(csvStore.row("pattern", "ITLIZ")).contains(entry("num-solutions", "5")).matches(map -> count(map.get("use"), 3), "fail use").matches(map -> count(map.get("nouse"), 3), "fail nouse").matches(map -> count(map.get("fumens"), 5), "fail fumens");
}
Also used : SimpleOperation(common.datastore.SimpleOperation) CSVStore(helper.CSVStore) BeforeEach(org.junit.jupiter.api.BeforeEach) Piece(core.mino.Piece) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IOException(java.io.IOException) Rotate(core.srs.Rotate) EntryPointMain(entry.EntryPointMain) Assertions.entry(org.assertj.core.api.Assertions.entry) Test(org.junit.jupiter.api.Test) Operations(common.datastore.Operations) Field(core.field.Field) _usecase(_usecase) Operation(common.datastore.Operation) FieldFactory(core.field.FieldFactory) Mino(core.mino.Mino) CSVStore(helper.CSVStore) Test(org.junit.jupiter.api.Test)

Example 9 with CSVStore

use of helper.CSVStore in project solution-finder by knewjade.

the class OutputFileHelper method loadCSVStore.

private static CSVStore loadCSVStore(Path path, List<String> columnNames) throws IOException {
    CSVStore csvStore = new CSVStore(columnNames);
    Files.lines(path).skip(// skip header
    1).forEach(csvStore::load);
    return csvStore;
}
Also used : CSVStore(helper.CSVStore)

Aggregations

CSVStore (helper.CSVStore)9 Test (org.junit.jupiter.api.Test)8 _usecase (_usecase)7 Operation (common.datastore.Operation)7 Operations (common.datastore.Operations)7 SimpleOperation (common.datastore.SimpleOperation)7 Field (core.field.Field)7 FieldFactory (core.field.FieldFactory)7 Mino (core.mino.Mino)7 Piece (core.mino.Piece)7 Rotate (core.srs.Rotate)7 EntryPointMain (entry.EntryPointMain)7 IOException (java.io.IOException)7 Arrays (java.util.Arrays)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 Assertions.entry (org.assertj.core.api.Assertions.entry)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7