aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-11-28 11:28:49 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-11-28 10:45:13 +0000
commit12b639970fc3ce08eada69d315470735fc23ef5f (patch)
tree9a8c162d2229fd8dfac9f10f11ed47446d047379 /tests
parent23f53dcbda305d3e2f593b4e0c566375af7dc0fb (diff)
MathUtils: Add exponential interpolation
Change-Id: I58bb26a6e921cbd1f5532bddcd6a6700ff80b94f Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/utils/mathutils/tst_mathutils.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/utils/mathutils/tst_mathutils.cpp b/tests/auto/utils/mathutils/tst_mathutils.cpp
index 30d2d8d6c59..a585868d994 100644
--- a/tests/auto/utils/mathutils/tst_mathutils.cpp
+++ b/tests/auto/utils/mathutils/tst_mathutils.cpp
@@ -16,6 +16,8 @@ private slots:
void interpolateLinear();
void interpolateTangential_data();
void interpolateTangential();
+ void interpolateExponential_data();
+ void interpolateExponential();
};
void tst_MathUtils::interpolateLinear_data()
@@ -72,6 +74,31 @@ void tst_MathUtils::interpolateTangential()
QCOMPARE(y, result);
}
+void tst_MathUtils::interpolateExponential_data()
+{
+ QTest::addColumn<int>("x");
+ QTest::addColumn<int>("xHalfLife");
+ QTest::addColumn<int>("y1");
+ QTest::addColumn<int>("y2");
+ QTest::addColumn<int>("result");
+
+ QTest::newRow("zero") << 0 << 8 << 10 << 20 << 10;
+ QTest::newRow("halfLife") << 8 << 8 << 10 << 20 << 15;
+ QTest::newRow("approxInfinity") << 1000 << 8 << 10 << 20 << 20;
+}
+
+void tst_MathUtils::interpolateExponential()
+{
+ QFETCH(int, x);
+ QFETCH(int, xHalfLife);
+ QFETCH(int, y1);
+ QFETCH(int, y2);
+ QFETCH(int, result);
+
+ const int y = MathUtils::interpolateExponential(x, xHalfLife, y1, y2);
+ QCOMPARE(y, result);
+}
+
QTEST_GUILESS_MAIN(tst_MathUtils)
#include "tst_mathutils.moc"