Search in sources :

Example 11 with ArgumentsSource

use of org.junit.jupiter.params.provider.ArgumentsSource in project solution-finder by knewjade.

the class CheckerNoHoldInvokerTest method random.

@LongTest
@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void random(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws FinderExecuteException, SyntaxException {
    Randoms randoms = new Randoms();
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    PerfectValidator validator = new PerfectValidator();
    CheckerNoHold<Action> checker = new CheckerNoHold<>(minoFactory, validator);
    for (int count = 0; count < 40; count++) {
        int maxClearLine = randoms.nextInt(3, 6);
        int maxDepth = randoms.nextIntClosed(3, 5);
        Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
        Field field = randoms.field(maxClearLine, maxDepth);
        PatternGenerator blocksGenerator = createPiecesGenerator(maxDepth);
        List<Pieces> searchingPieces = blocksGenerator.blocksStream().collect(Collectors.toList());
        ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
        AnalyzeTree tree = runTestCase(invoker, field, searchingPieces, maxClearLine, maxDepth);
        for (Pieces pieces : searchingPieces) {
            boolean check = checker.check(field, pieces.getPieces(), candidate, maxClearLine, maxDepth);
            assertThat(tree.isSucceed(pieces)).isEqualTo(check);
        }
    }
}
Also used : Action(common.datastore.action.Action) PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) MinoRotation(core.srs.MinoRotation) LockedCandidate(core.action.candidate.LockedCandidate) Field(core.field.Field) Randoms(lib.Randoms) CheckerNoHold(searcher.checker.CheckerNoHold) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) PerfectValidator(searcher.common.validator.PerfectValidator) Pieces(common.datastore.blocks.Pieces) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) LongTest(module.LongTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 12 with ArgumentsSource

use of org.junit.jupiter.params.provider.ArgumentsSource in project solution-finder by knewjade.

the class CheckerNoHoldInvokerTest method testSearch8.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testSearch8(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p5");
    int maxClearLine = 4;
    int maxDepth = 4;
    String marks = "" + "XXXXXX____" + "XXXXX_____" + "XXXXXX____" + "XXXXXXX___" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: twitter by @???
    assertThat(tree.getSuccessPercent()).isEqualTo(609 / 2520.0);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 13 with ArgumentsSource

use of org.junit.jupiter.params.provider.ArgumentsSource in project solution-finder by knewjade.

the class CheckerNoHoldInvokerTest method testCase14.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testCase14(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    // Invoker
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p5");
    int maxClearLine = 4;
    int maxDepth = 4;
    // Field
    String marks = "" + "XXXX______" + "XXXX_____X" + "XXXXXXXXXX" + "XXXX_____X" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: myself 20170415
    assertThat(tree.getSuccessPercent()).isEqualTo(309 / 2520.0);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 14 with ArgumentsSource

use of org.junit.jupiter.params.provider.ArgumentsSource in project solution-finder by knewjade.

the class CheckerUsingHoldInvokerTest method testSearch7.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testSearch7(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p5");
    int maxClearLine = 4;
    int maxDepth = 4;
    String marks = "" + "XXXXX_____" + "XXXXXX____" + "XXXXXXX___" + "XXXXXX____" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: twitter by @???
    assertThat(tree.getSuccessPercent()).isEqualTo(1672 / 2520.0);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 15 with ArgumentsSource

use of org.junit.jupiter.params.provider.ArgumentsSource in project solution-finder by knewjade.

the class CheckerUsingHoldInvokerTest method testSearch8.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testSearch8(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p5");
    int maxClearLine = 4;
    int maxDepth = 4;
    String marks = "" + "XXXXXX____" + "XXXXX_____" + "XXXXXX____" + "XXXXXXX___" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: twitter by @???
    assertThat(tree.getSuccessPercent()).isEqualTo(1928 / 2520.0);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Aggregations

ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)50 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)49 LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)27 PatternGenerator (common.pattern.PatternGenerator)27 AnalyzeTree (common.tree.AnalyzeTree)27 LongTest (module.LongTest)16 Log (_usecase.Log)10 TestCase (com.cadenzauk.core.junit.TestCase)7 TestDatabase.testDatabase (com.cadenzauk.siesta.model.TestDatabase.testDatabase)7 Action (common.datastore.action.Action)7 Field (core.field.Field)7 UncheckedAutoCloseable (com.cadenzauk.core.lang.UncheckedAutoCloseable)6 LockedCandidate (core.action.candidate.LockedCandidate)6 Piece (core.mino.Piece)5 LockedReachable (core.action.reachable.LockedReachable)4 RandomValues.randomZonedDateTime (com.cadenzauk.core.RandomValues.randomZonedDateTime)3 TestRow (com.cadenzauk.siesta.model.TestRow)3 MinoFactory (core.mino.MinoFactory)3 MinoShifter (core.mino.MinoShifter)3 MinoRotation (core.srs.MinoRotation)3