Search in sources :

Example 1 with CSVStore

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

the class PathCSVCaseTest method use1WithoutHold.

@Test
void use1WithoutHold() throws Exception {
    String fumen = "v115@9gF8DeG8CeH8BeG8MeAgH";
    String command = String.format("path -t %s -p *p3 -f csv -k use -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.foundPieceCombinations(35));
    // column: [use, num-solutions, num-patterns, fumens, patterns]
    CSVStore csvStore = OutputFileHelper.loadPathUseCSV();
    assertThat(csvStore.size()).isEqualTo(35);
    assertThat(csvStore.row("use", "TJS")).contains(entry("use", "TJS")).contains(entry("num-solutions", "0")).contains(entry("num-patterns", "0")).contains(entry("fumens", "")).contains(entry("patterns", ""));
    assertThat(csvStore.row("use", "ILZ")).contains(entry("use", "ILZ")).contains(entry("num-solutions", "1")).contains(entry("num-patterns", "3")).contains(entry("fumens", "v115@9gF8zhG8BtglH8BtG8ilJeAgWDA6SdBA")).matches(map -> count(map.get("patterns"), 3), "fail patterns");
    assertThat(csvStore.row("use", "TIJ")).contains(entry("use", "TIJ")).contains(entry("num-solutions", "2")).contains(entry("num-patterns", "5")).matches(map -> count(map.get("fumens"), 2), "fail fumens").matches(map -> count(map.get("patterns"), 5), "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 2 with CSVStore

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

the class PathCSVCaseTest method use1.

@Test
void use1() throws Exception {
    String fumen = "v115@9gF8DeG8CeH8BeG8MeAgH";
    String command = String.format("path -t %s -p *p3 -f csv -k use", fumen);
    Log log = RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    assertThat(log.getReturnCode()).isEqualTo(0);
    assertThat(log.getOutput()).contains(Messages.foundPath(18)).contains(Messages.foundPieceCombinations(35));
    // column: [use, num-solutions, num-patterns, fumens, patterns]
    CSVStore csvStore = OutputFileHelper.loadPathUseCSV();
    assertThat(csvStore.size()).isEqualTo(35);
    assertThat(csvStore.row("use", "JSO")).contains(entry("use", "JSO")).contains(entry("num-solutions", "0")).contains(entry("num-patterns", "0")).contains(entry("fumens", "")).contains(entry("patterns", ""));
    assertThat(csvStore.row("use", "TIO")).contains(entry("use", "TIO")).contains(entry("num-solutions", "1")).contains(entry("num-patterns", "6")).contains(entry("fumens", "v115@9gF8zhG8RpwwH8xwG8RpwwJeAgWDAUXdBA")).matches(map -> count(map.get("patterns"), 6), "fail patterns");
    assertThat(csvStore.row("use", "TSZ")).contains(entry("use", "TSZ")).contains(entry("num-solutions", "2")).contains(entry("num-patterns", "4")).matches(map -> count(map.get("fumens"), 2), "fail fumens").matches(map -> count(map.get("patterns"), 4), "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 3 with CSVStore

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

the class PathCSVCaseTest method solution1.

@Test
void solution1() throws Exception {
    String fumen = "v115@9gF8DeG8CeH8BeG8MeAgH";
    String command = String.format("path -t %s -p *p3 -f csv -k solution", fumen);
    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", "4")).contains(entry("solutions", "TLZ")).matches(map -> count(map.get("patterns"), 4), "fail patterns");
    assertThat(csvStore.row("fumen", "http://fumen.zui.jp/?v115@9gF8zhG8BtglH8BtG8ilJeAgWDA6SdBA")).contains(entry("use", "ILZ")).contains(entry("num-solutions", "3")).contains(entry("num-patterns", "6")).matches(map -> count(map.get("solutions"), 3), "fail solutions").matches(map -> count(map.get("patterns"), 6), "fail patterns");
    assertThat(csvStore.row("fumen", "http://fumen.zui.jp/?v115@9gF8ywwhG8wwg0whH8g0whG8h0whJeAgWDAK+1BA")).contains(entry("use", "TIJ")).contains(entry("num-solutions", "2")).contains(entry("num-patterns", "4")).matches(map -> count(map.get("solutions"), 2), "fail solutions").matches(map -> count(map.get("patterns"), 4), "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 4 with CSVStore

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

the class PathCSVCaseTest method pattern1.

@Test
void pattern1() throws Exception {
    String fumen = "v115@9gF8DeG8CeH8BeG8MeAgH";
    String command = String.format("path -t %s -p *p4 -f csv -k pattern", 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", "JZSO")).contains(entry("num-solutions", "0")).contains(entry("use", "")).contains(entry("nouse", "")).contains(entry("fumens", ""));
    assertThat(csvStore.row("pattern", "STOZ")).contains(entry("num-solutions", "1")).contains(entry("use", "TSZ")).contains(entry("nouse", "O")).contains(entry("fumens", "v115@9gF8BtR4G8R4wwH8xwG8BtwwJeAgWDAUtDCA"));
    assertThat(csvStore.row("pattern", "SLZO")).contains(entry("num-solutions", "2")).contains(entry("use", "LSZ")).contains(entry("nouse", "O")).matches(map -> count(map.get("fumens"), 2), "fail fumens");
    assertThat(csvStore.row("pattern", "TSZL")).contains(entry("num-solutions", "4")).matches(map -> count(map.get("use"), 3), "fail use").matches(map -> count(map.get("nouse"), 3), "fail nouse").matches(map -> count(map.get("fumens"), 4), "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 5 with CSVStore

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

the class PathCSVCaseTest method pattern3.

@Test
void pattern3() throws Exception {
    // reservedオプション
    /*
        _____XXXXX
        IIIIXXXXXX
        ___XXXXXXX
        ____XXXXXX
         */
    String fumen = "v115@ChE8DeF8CeG8DeF8JexEJ";
    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(14)).contains(Messages.success(400, 840));
    // column: [pattern, num-solutions, use, nouse, fumens]
    CSVStore csvStore = OutputFileHelper.loadPathPatternCSV();
    assertThat(csvStore.size()).isEqualTo(840);
    assertThat(csvStore.row("pattern", "ITJSZ")).contains(entry("num-solutions", "0")).contains(entry("use", "")).contains(entry("nouse", "")).contains(entry("fumens", ""));
    assertThat(csvStore.row("pattern", "ISOJL")).contains(entry("num-solutions", "1")).contains(entry("use", "IJSO")).contains(entry("nouse", "L")).contains(entry("fumens", "v115@9gi0R4E8zhF8Rpg0G8RpR4F8JeAgWEAPentC"));
    assertThat(csvStore.row("pattern", "ITLSI")).contains(entry("num-solutions", "3")).contains(entry("use", "TILS")).contains(entry("nouse", "I")).matches(map -> count(map.get("fumens"), 3), "fail fumens");
    assertThat(csvStore.row("pattern", "ILTSZ")).contains(entry("num-solutions", "4")).matches(map -> count(map.get("use"), 2), "fail use").matches(map -> count(map.get("nouse"), 2), "fail nouse").matches(map -> count(map.get("fumens"), 4), "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)

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