Squashed 'external/gainput/' content from commit 2be0a50

git-subtree-dir: external/gainput
git-subtree-split: 2be0a50089eafcc6fccb66142180082e48f27f4c
This commit is contained in:
Simone
2024-01-22 08:51:55 +01:00
commit 4e42229bdd
170 changed files with 31921 additions and 0 deletions

48
test/test_inputstate.cpp Normal file
View 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));
}
}