|
|
|
@ -42,6 +42,7 @@ struct FunctionsTest: Corrade::TestSuite::Tester { |
|
|
|
void max(); |
|
|
|
void max(); |
|
|
|
void maxList(); |
|
|
|
void maxList(); |
|
|
|
void minmax(); |
|
|
|
void minmax(); |
|
|
|
|
|
|
|
void minmaxList(); |
|
|
|
void clamp(); |
|
|
|
void clamp(); |
|
|
|
void nanPropagation(); |
|
|
|
void nanPropagation(); |
|
|
|
|
|
|
|
|
|
|
|
@ -86,6 +87,7 @@ FunctionsTest::FunctionsTest() { |
|
|
|
&FunctionsTest::max, |
|
|
|
&FunctionsTest::max, |
|
|
|
&FunctionsTest::maxList, |
|
|
|
&FunctionsTest::maxList, |
|
|
|
&FunctionsTest::minmax, |
|
|
|
&FunctionsTest::minmax, |
|
|
|
|
|
|
|
&FunctionsTest::minmaxList, |
|
|
|
&FunctionsTest::clamp, |
|
|
|
&FunctionsTest::clamp, |
|
|
|
&FunctionsTest::nanPropagation, |
|
|
|
&FunctionsTest::nanPropagation, |
|
|
|
|
|
|
|
|
|
|
|
@ -171,6 +173,24 @@ void FunctionsTest::minmax() { |
|
|
|
CORRADE_COMPARE_AS(Math::minmax(b, a), expectedVector, std::pair<Vector3, Vector3>); |
|
|
|
CORRADE_COMPARE_AS(Math::minmax(b, a), expectedVector, std::pair<Vector3, Vector3>); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FunctionsTest::minmaxList() { |
|
|
|
|
|
|
|
const auto expected = std::make_pair(-3.0f, 2.0f); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({-1.0f, 2.0f, -3.0f}), expected); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({-1.0f, -3.0f, 2.0f}), expected); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({2.0f, -1.0f, -3.0f}), expected); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({2.0f, -3.0f, -1.0f}), expected); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({-3.0f, 2.0f, -1.0f}), expected); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({-3.0f, -1.0f, 2.0f}), expected); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::pair<Vector2, Vector2> expectedVec{Vector2{-3.0f, -2.0f}, Vector2{2.0f, 3.0f}}; |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({Vector2{-1.0f, 3.0f}, Vector2{2.0f, 1.0f}, Vector2{-3.0f, -2.0f}}), expectedVec); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({Vector2{-1.0f, 1.0f}, Vector2{-3.0f, 3.0f}, Vector2{2.0f, -2.0f}}), expectedVec); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({Vector2{2.0f, -2.0f}, Vector2{-1.0f, 1.0f}, Vector2{-3.0f, 3.0f}}), expectedVec); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({Vector2{2.0f, 1.0f}, Vector2{-3.0f, -2.0f}, Vector2{-1.0f, 3.0f}}), expectedVec); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({Vector2{-3.0f, 3.0f}, Vector2{2.0f, -2.0f}, Vector2{-1.0f, 1.0f}}), expectedVec); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::minmax({Vector2{-3.0f, -2.0f}, Vector2{-1.0f, 3.0f}, Vector2{2.0f, 1.0f}}), expectedVec); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void FunctionsTest::clamp() { |
|
|
|
void FunctionsTest::clamp() { |
|
|
|
CORRADE_COMPARE(Math::clamp(0.5f, -1.0f, 5.0f), 0.5f); |
|
|
|
CORRADE_COMPARE(Math::clamp(0.5f, -1.0f, 5.0f), 0.5f); |
|
|
|
CORRADE_COMPARE(Math::clamp(-1.6f, -1.0f, 5.0f), -1.0f); |
|
|
|
CORRADE_COMPARE(Math::clamp(-1.6f, -1.0f, 5.0f), -1.0f); |
|
|
|
|