// SPDX-License-Identifier: GPL-3.0-or-later // Copyright 2019 Juan Palacios #include #include "common/mathutils.h" #include namespace Tests::Utils::Math { TEST_CASE("MathUtils tests", "[Utils][Math]") { SECTION("linearNorm") { std::vector values{1, 50, 100}; std::pair oldRange(1, 100); std::pair newRange(1, 50); std::vector normValues{1, 25, 50}; ::Utils::Math::linearNorm(values, oldRange, newRange); REQUIRE(values == normValues); } SECTION("lerpX") { auto p1 = std::make_pair(0, 0); auto p2 = std::make_pair(10, 10); REQUIRE(::Utils::Math::lerpX(5, p1, p2) == 5); } SECTION("lerpY") { auto p1 = std::make_pair(0, 0); auto p2 = std::make_pair(10, 10); REQUIRE(::Utils::Math::lerpY(5, p1, p2) == 5); } } } // namespace Tests::Utils::Math