package queue;

import static queue.Queues.*;

import base.Selector;
import base.TestCounter;
import java.util.List;
import java.util.function.Consumer;

/**
 * @author Georgiy Korneev (kgeorgiy@kgeorgiy.info)
 */
public final class QueueTest {

    public static final Selector SELECTOR = new Selector(QueueTest.class)
        .variant("Base", variant(QueueModel.class, d -> () -> d))
        .variant("3637", variant(ContainsModel.class, d -> () -> d, CONTAINS))
        .variant("3839", variant(NthModel.class, d -> () -> d, NTH))
        .variant(
            "3435",
            variant(RemoveIfModel.class, d -> () -> d, REMOVE_IF_TEST)
        )
        .variant(
            "3233",
            variant(RemoveEqModel.class, d -> () -> d, REMOVE_EQ_TEST)
        );

    private QueueTest() {}

    public static void main(final String... args) {
        SELECTOR.main(args);
    }

    /* package-private */ static <
        M extends QueueModel,
        T extends QueueChecker<M>
    > Consumer<TestCounter> variant(
        final Class<M> type,
        final T tester,
        final Queues.Splitter<M> splitter
    ) {
        return new QueueTester<>(type, tester, splitter)::test;
    }

    /* package-private */ static <
        M extends QueueModel,
        T extends QueueChecker<M>
    > Consumer<TestCounter> variant(final Class<M> type, final T tester) {
        return variant(type, tester, (t, q, r) -> List.of());
    }
}
