Merge commit '4e42229bdd980ab50da8b83b1aa1b0877b5a9ef6' as 'external/gainput'
This commit is contained in:
48
external/gainput/test/test_inputstate.cpp
vendored
Normal file
48
external/gainput/test/test_inputstate.cpp
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <gainput/gainput.h>
|
||||
|
||||
using namespace gainput;
|
||||
|
||||
const unsigned ButtonCount = 15;
|
||||
|
||||
TEST_CASE("InputState", "")
|
||||
{
|
||||
InputState state(GetDefaultAllocator(), ButtonCount);
|
||||
InputState state2(GetDefaultAllocator(), ButtonCount);
|
||||
|
||||
for (unsigned i = 0; i < ButtonCount; ++i)
|
||||
{
|
||||
REQUIRE(!state.GetBool(i));
|
||||
REQUIRE(state.GetFloat(i) == 0.0f);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < ButtonCount; ++i)
|
||||
{
|
||||
const bool s = i & 1;
|
||||
state.Set(i, s);
|
||||
REQUIRE(state.GetBool(i) == s);
|
||||
}
|
||||
|
||||
state2 = state;
|
||||
for (unsigned i = 0; i < ButtonCount; ++i)
|
||||
{
|
||||
REQUIRE(state2.GetBool(i) == state.GetBool(i));
|
||||
}
|
||||
|
||||
float s = 0.0f;
|
||||
for (unsigned i = 0; i < ButtonCount; ++i)
|
||||
{
|
||||
state.Set(i, s);
|
||||
REQUIRE(state.GetFloat(i) == s);
|
||||
s += float(i)*0.0354f;
|
||||
}
|
||||
|
||||
state2 = state;
|
||||
for (unsigned i = 0; i < ButtonCount; ++i)
|
||||
{
|
||||
REQUIRE(state2.GetFloat(i) == state.GetFloat(i));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user