// SPDX-License-Identifier: MPL-2.0 #include "sequa/3d/input.hpp" #include "sequa/3d/null_adapter.hpp" #include #include using namespace sequa::three_d; TEST_CASE("quantize_axis : bornes, arrondi, valeurs non finies") { CHECK(quantize_axis(0.0) == 0); CHECK(quantize_axis(1.0) == axis_max); CHECK(quantize_axis(-1.0) == -axis_max); CHECK(quantize_axis(0.5) == 16384); // 16383,5 arrondi au plus proche CHECK(quantize_axis(-0.5) == -16384); CHECK(quantize_axis(3.0) == axis_max); CHECK(quantize_axis(-3.0) == -axis_max); CHECK(quantize_axis(std::numeric_limits::quiet_NaN()) == 0); CHECK(quantize_axis(std::numeric_limits::infinity()) == 0); } TEST_CASE("PlayerInput : neutre et egalite") { CHECK(PlayerInput{}.is_neutral()); CHECK_FALSE(PlayerInput{1, 0, 0}.is_neutral()); CHECK_FALSE(PlayerInput{0, 0, -5}.is_neutral()); CHECK(PlayerInput{1, 2, 3} == PlayerInput{1, 2, 3}); CHECK_FALSE(PlayerInput{1, 2, 3} == PlayerInput{1, 2, 4}); } TEST_CASE("NullEngineAdapter : entrees seulement si declarees et demarre") { NullEngineAdapter silent; EngineConfig config; config.headless = true; REQUIRE_FALSE(silent.start(config)); CHECK_FALSE(silent.poll_input().has_value()); // capacite non declaree EngineCapabilities caps{"null", "0", BufferSet::all(), false, true, 0, 0}; caps.player_input = true; NullEngineAdapter adapter(caps); CHECK_FALSE(adapter.poll_input().has_value()); // pas encore demarre REQUIRE_FALSE(adapter.start(config)); REQUIRE(adapter.poll_input().has_value()); CHECK(adapter.poll_input()->is_neutral()); adapter.set_input(PlayerInput{1, axis_max, 0}); CHECK(*adapter.poll_input() == PlayerInput{1, axis_max, 0}); adapter.stop(); CHECK_FALSE(adapter.poll_input().has_value()); }