void StateMachineTest::test() {
    StateMachine m;
    m.addTransitions({
        {State::Start,  Input::KeyA,    State::End},
        {State::End,    Input::KeyB,    State::Start}
    });

    std::ostringstream out;
    Debug redirectDebug{&out};

    Interconnect::connect(m, &StateMachine::entered<State::Start>,
        [](State s) { Debug() << "start entered, previous" << std::uint8_t(s); });
    Interconnect::connect(m, &StateMachine::exited<State::Start>,
        [](State s) { Debug() << "start exited, next" << std::uint8_t(s); });
    Interconnect::connect(m, &StateMachine::entered<State::End>,
        [](State s) { Debug() << "end entered, previous" << std::uint8_t(s); });
    Interconnect::connect(m, &StateMachine::exited<State::End>,
        [](State s) { Debug() << "end exited, next" << std::uint8_t(s); });

    Interconnect::connect(m, &StateMachine::stepped<State::End, State::Start>,
        []() { Debug() << "going from end to start"; });
    Interconnect::connect(m, &StateMachine::stepped<State::Start, State::End>,
        []() { Debug() << "going from start to end"; });

    m.step(Input::KeyA)
     .step(Input::KeyB);
    CORRADE_COMPARE(out.str(), "start exited, next 1\n"
                               "going from start to end\n"
                               "end entered, previous 0\n"
                               "end exited, next 0\n"
                               "going from end to start\n"
                               "start entered, previous 1\n");
}
void StateMachineTest::test() {
    enum class State: std::uint8_t {
        Start,
        End
    };

    enum class Input: std::uint8_t {
        KeyA,
        KeyB
    };

    typedef Interconnect::StateMachine<2, 2, State, Input> StateMachine;

    StateMachine m;
    m.addTransitions({
        {State::Start,  Input::KeyA,    State::End},
        {State::End,    Input::KeyB,    State::Start}
    });

    std::ostringstream out;
    Debug::setOutput(&out);

    Interconnect::connect(m, &StateMachine::entered<State::Start>,
        [](State s) { Debug() << "start entered, previous" << std::uint8_t(s); });
    Interconnect::connect(m, &StateMachine::exited<State::Start>,
        [](State s) { Debug() << "start exited, next" << std::uint8_t(s); });
    Interconnect::connect(m, &StateMachine::entered<State::End>,
        [](State s) { Debug() << "end entered, previous" << std::uint8_t(s); });
    Interconnect::connect(m, &StateMachine::exited<State::End>,
        [](State s) { Debug() << "end exited, next" << std::uint8_t(s); });

    Interconnect::connect(m, &StateMachine::stepped<State::End, State::Start>,
        []() { Debug() << "going from end to start"; });
    Interconnect::connect(m, &StateMachine::stepped<State::Start, State::End>,
        []() { Debug() << "going from start to end"; });

    m.step(Input::KeyA)
     .step(Input::KeyB);
    CORRADE_COMPARE(out.str(), "start exited, next 1\n"
                               "going from start to end\n"
                               "end entered, previous 0\n"
                               "end exited, next 0\n"
                               "going from end to start\n"
                               "start entered, previous 1\n");
}