|
|
|
|
@ -34,6 +34,9 @@ namespace Magnum { namespace Math { namespace Test {
|
|
|
|
|
struct FunctionsTest: Corrade::TestSuite::Tester { |
|
|
|
|
explicit FunctionsTest(); |
|
|
|
|
|
|
|
|
|
void powIntegral(); |
|
|
|
|
void pow(); |
|
|
|
|
|
|
|
|
|
void min(); |
|
|
|
|
void minList(); |
|
|
|
|
void max(); |
|
|
|
|
@ -64,8 +67,6 @@ struct FunctionsTest: Corrade::TestSuite::Tester {
|
|
|
|
|
|
|
|
|
|
void normalizeTypeDeduction(); |
|
|
|
|
|
|
|
|
|
void powIntegral(); |
|
|
|
|
void pow(); |
|
|
|
|
void logIntegral(); |
|
|
|
|
void log2(); |
|
|
|
|
void log(); |
|
|
|
|
@ -85,7 +86,10 @@ typedef Math::Vector3<Byte> Vector3b;
|
|
|
|
|
typedef Math::Vector3<Int> Vector3i; |
|
|
|
|
|
|
|
|
|
FunctionsTest::FunctionsTest() { |
|
|
|
|
addTests({&FunctionsTest::min, |
|
|
|
|
addTests({&FunctionsTest::powIntegral, |
|
|
|
|
&FunctionsTest::pow, |
|
|
|
|
|
|
|
|
|
&FunctionsTest::min, |
|
|
|
|
&FunctionsTest::minList, |
|
|
|
|
&FunctionsTest::max, |
|
|
|
|
&FunctionsTest::maxList, |
|
|
|
|
@ -115,8 +119,6 @@ FunctionsTest::FunctionsTest() {
|
|
|
|
|
|
|
|
|
|
&FunctionsTest::normalizeTypeDeduction, |
|
|
|
|
|
|
|
|
|
&FunctionsTest::powIntegral, |
|
|
|
|
&FunctionsTest::pow, |
|
|
|
|
&FunctionsTest::logIntegral, |
|
|
|
|
&FunctionsTest::log2, |
|
|
|
|
&FunctionsTest::log, |
|
|
|
|
@ -126,6 +128,23 @@ FunctionsTest::FunctionsTest() {
|
|
|
|
|
&FunctionsTest::trigonometricWithBase}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FunctionsTest::powIntegral() { |
|
|
|
|
CORRADE_COMPARE(Math::pow<10>(2ul), 1024ul); |
|
|
|
|
CORRADE_COMPARE(Math::pow<0>(3ul), 1ul); |
|
|
|
|
CORRADE_COMPARE(Math::pow<2>(2.0f), 4.0f); |
|
|
|
|
|
|
|
|
|
/* Constant expression */ |
|
|
|
|
constexpr Int a = Math::pow<3>(5); |
|
|
|
|
CORRADE_COMPARE(a, 125); |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(Math::pow<2>(Vector3{2.0f, -3.0f, 1.5f}), (Vector3{4.0f, 9.0f, 2.25f})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FunctionsTest::pow() { |
|
|
|
|
CORRADE_COMPARE(Math::pow(2.0f, 0.5f), 1.414213562f); |
|
|
|
|
CORRADE_COMPARE(Math::pow(Vector3{2.0f, 9.0f, 25.0f}, 0.5f), (Vector3{1.414213562f, 3.0f, 5.0f})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FunctionsTest::min() { |
|
|
|
|
CORRADE_COMPARE(Math::min(5, 9), 5); |
|
|
|
|
CORRADE_COMPARE(Math::min(Vector3i(5, -3, 2), Vector3i(9, -5, 18)), Vector3i(5, -5, 2)); |
|
|
|
|
@ -437,20 +456,6 @@ void FunctionsTest::normalizeTypeDeduction() {
|
|
|
|
|
CORRADE_COMPARE((Math::normalize<Float, Byte>('\x7F')), 1.0f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FunctionsTest::powIntegral() { |
|
|
|
|
CORRADE_COMPARE(Math::pow<10>(2ul), 1024ul); |
|
|
|
|
CORRADE_COMPARE(Math::pow<0>(3ul), 1ul); |
|
|
|
|
CORRADE_COMPARE(Math::pow<2>(2.0f), 4.0f); |
|
|
|
|
|
|
|
|
|
/* Constant expression */ |
|
|
|
|
constexpr Int a = Math::pow<3>(5); |
|
|
|
|
CORRADE_COMPARE(a, 125); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FunctionsTest::pow() { |
|
|
|
|
CORRADE_COMPARE(Math::pow(2.0f, 0.5f), 1.414213562f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FunctionsTest::logIntegral() { |
|
|
|
|
CORRADE_COMPARE(Math::log(2, 256), 8ul); |
|
|
|
|
CORRADE_COMPARE(Math::log(256, 2), 0ul); |
|
|
|
|
|