summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2018-07-04 14:46:34 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-07-10 09:41:04 +0000
commita772c0f3cc85baed7434c0e0c8d2a6a7b3601364 (patch)
treef1a4491fb0797b5a067e6ba5fd61312e08bc719d /tests
parent67c08c0fb7101291bb44998f52ea8b087e33b1f2 (diff)
More fuzzy evaluation when calculating roots
If the discriminant is close to zero, evaluate it as being zero. Change-Id: Ief2624dd512d703e44d8a0c63431baef3cee7c45 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/animation/bezierevaluator/tst_bezierevaluator.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/animation/bezierevaluator/tst_bezierevaluator.cpp b/tests/auto/animation/bezierevaluator/tst_bezierevaluator.cpp
index c61ce2d7e..06389bd36 100644
--- a/tests/auto/animation/bezierevaluator/tst_bezierevaluator.cpp
+++ b/tests/auto/animation/bezierevaluator/tst_bezierevaluator.cpp
@@ -187,6 +187,19 @@ private Q_SLOTS:
roots[2] = -1.39297f;
QTest::newRow("a=-0.75, b=0.75, c=2.5, d=0") << a << b << c << d << roots.size() << roots;
roots.clear();
+
+ // Case that produces a discriminant that is close enough to zero that it should be
+ // evaluated as zero.
+ // Expected roots = 0.0, ~1.5
+ a = -3.998f;
+ b = 5.997f;
+ c = 0.0f;
+ d = 0.0f;
+ roots.resize(2);
+ roots[0] = 1.5f;
+ roots[1] = 0.0f;
+ QTest::newRow("a=-3.998, b=5.997, c=0, d=0") << a << b << c << d << roots.size() << roots;
+ roots.clear();
}
void checkFindCubicRoots()