Former-commit-id: 8295c8c806237bd8e19b1552a49261a4ffe88f25 [formerly 787c63351091093758db9e757f5fb25503fe1148] [formerly 2d6ee7f2e25afe0cbefb253cfd3ff14a98fd0d1c [formerly 478af98f46f86377def455f096426cfc8b54fb63]] Former-commit-id: 96b7dc76d50ed661f9a8a0d785d5fc0d00b3a009 [formerly 4f4129ba5e902fece9d58530c40c8d134a05cc27] Former-commit-id: bf52731510dbb1269be506e9ebea6f0733045b4a
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());
|
|
}
|
|
}
|
|
}
|
|
}
|