Former-commit-id: 8bae2463a80f57c10758af26bae23b2fc5c38eb3 [formerly 27831c3a673deb90d402d76bfac33c9c1c45f1fb] [formerly 40c188bae9bcf7c79592e61b1d6dd19eebcf27bc [formerly 4f69ef25f21ef9ee385044c1dd86c51a0e44fc0d]] Former-commit-id: bedf58687a28842fa11dfa7abb1667fc72a7789b [formerly fda4ac3ef072a3ed0ef85d158d739b15850f04cd] Former-commit-id: 88f150190da78ec9b76a5feac34634b800b4d3e2
50 lines
858 B
C++
50 lines
858 B
C++
#include <NDK/StateMachine.hpp>
|
|
#include <Catch/catch.hpp>
|
|
|
|
class TestState : public Ndk::State
|
|
{
|
|
public:
|
|
void Enter(Ndk::StateMachine& fsm) override
|
|
{
|
|
m_isUpdated = false;
|
|
}
|
|
|
|
bool IsUpdated() const
|
|
{
|
|
return m_isUpdated;
|
|
}
|
|
|
|
void Leave(Ndk::StateMachine& fsm) override
|
|
{
|
|
}
|
|
|
|
bool Update(Ndk::StateMachine& fsm, float elapsedTime) override
|
|
{
|
|
m_isUpdated = true;
|
|
return true;
|
|
}
|
|
|
|
private:
|
|
bool m_isUpdated;
|
|
};
|
|
|
|
SCENARIO("State & StateMachine", "[NDK][STATE]")
|
|
{
|
|
GIVEN("A statemachine with our TestState")
|
|
{
|
|
std::shared_ptr<TestState> testState = std::make_shared<TestState>();
|
|
Ndk::StateMachine stateMachine(testState);
|
|
REQUIRE(!testState->IsUpdated());
|
|
|
|
WHEN("We update our machine")
|
|
{
|
|
stateMachine.Update(1.f);
|
|
|
|
THEN("Our state has been updated")
|
|
{
|
|
REQUIRE(testState->IsUpdated());
|
|
}
|
|
}
|
|
}
|
|
}
|