Search in sources :

Example 26 with LongTest

use of module.LongTest in project solution-finder by knewjade.

the class PercentCountCaseTest method hold1.

@ParameterizedTest
@ArgumentsSource(Hold1TestCase.class)
@LongTest
void hold1(String command, int success, int all) throws Exception {
    Log log = RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    assertThat(log.getOutput()).contains(Messages.useHold()).contains(Messages.success(success, all));
}
Also used : Log(_usecase.Log) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) LongTest(module.LongTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 27 with LongTest

use of module.LongTest in project solution-finder by knewjade.

the class PercentCountCaseTest method hold2.

@ParameterizedTest
@ArgumentsSource(Hold2TestCase.class)
@LongTest
void hold2(String command, int success, int all) throws Exception {
    Log log = RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    assertThat(log.getOutput()).contains(Messages.useHold()).contains(Messages.success(success, all));
}
Also used : Log(_usecase.Log) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) LongTest(module.LongTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 28 with LongTest

use of module.LongTest in project solution-finder by knewjade.

the class PercentCountCaseTest method noHold1.

@ParameterizedTest
@ArgumentsSource(NoHold1TestCase.class)
@LongTest
void noHold1(String command, int success, int all) throws Exception {
    Log log = RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    assertThat(log.getOutput()).contains(Messages.noUseHold()).contains(Messages.success(success, all));
}
Also used : Log(_usecase.Log) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) LongTest(module.LongTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 29 with LongTest

use of module.LongTest in project solution-finder by knewjade.

the class PercentCountCaseTest method noHold2.

@ParameterizedTest
@ArgumentsSource(NoHold2TestCase.class)
@LongTest
void noHold2(String command, int success, int all) throws Exception {
    Log log = RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    assertThat(log.getOutput()).contains(Messages.noUseHold()).contains(Messages.success(success, all));
}
Also used : Log(_usecase.Log) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) LongTest(module.LongTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 30 with LongTest

use of module.LongTest in project solution-finder by knewjade.

the class BuildUpTest method cansBuildRandomLongByCheck.

@Test
@LongTest
void cansBuildRandomLongByCheck() {
    Randoms randoms = new Randoms();
    // Create field
    int height = 4;
    // Initialize
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    PerfectValidator validator = new PerfectValidator();
    CheckerUsingHold<Action> checker = new CheckerUsingHold<>(minoFactory, validator);
    Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, height);
    LockedReachable reachable = new LockedReachable(minoFactory, minoShifter, minoRotation, height);
    AtomicInteger counter = new AtomicInteger();
    for (int count = 0; count < 100; count++) {
        // Pickup solution from checker
        int numOfMinos = randoms.nextIntClosed(7, 10);
        Field field = randoms.field(height, numOfMinos);
        List<Piece> pieces = randoms.blocks(numOfMinos);
        boolean check = checker.check(field, pieces, candidate, height, numOfMinos);
        if (check) {
            counter.incrementAndGet();
            Stream<Operation> operationStream = ResultHelper.createOperationStream(checker.getResult());
            Operations operations = new Operations(operationStream);
            List<MinoOperationWithKey> operationWithKeys = OperationTransform.parseToOperationWithKeys(field, operations, minoFactory, height);
            assertThat(BuildUp.cansBuild(field, operationWithKeys, height, reachable)).as(FieldView.toString(field) + pieces).isTrue();
        }
    }
    System.out.println(counter);
}
Also used : Action(common.datastore.action.Action) MinoRotation(core.srs.MinoRotation) LockedCandidate(core.action.candidate.LockedCandidate) ColumnField(core.column_field.ColumnField) InOutPairField(searcher.pack.InOutPairField) Field(core.field.Field) Randoms(lib.Randoms) CheckerUsingHold(searcher.checker.CheckerUsingHold) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Piece(core.mino.Piece) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) LockedReachable(core.action.reachable.LockedReachable) PerfectValidator(searcher.common.validator.PerfectValidator) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest) LongTest(module.LongTest)

Aggregations

LongTest (module.LongTest)44 Test (org.junit.jupiter.api.Test)28 Piece (core.mino.Piece)26 Field (core.field.Field)24 Randoms (lib.Randoms)20 Action (common.datastore.action.Action)19 LockedCandidate (core.action.candidate.LockedCandidate)18 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)18 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)16 Log (_usecase.Log)13 MinoFactory (core.mino.MinoFactory)12 MinoShifter (core.mino.MinoShifter)12 MinoRotation (core.srs.MinoRotation)10 LockedReachable (core.action.reachable.LockedReachable)9 List (java.util.List)9 LongPieces (common.datastore.blocks.LongPieces)8 SizedBit (searcher.pack.SizedBit)8 ColumnField (core.column_field.ColumnField)7 Collectors (java.util.stream.Collectors)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7