summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-11-23 12:46:01 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-11-24 14:22:51 +0100
commitc9765d6ae3ffb7ad50f42457f709ad5eef60ba22 (patch)
treee0e1a0d3205861f838c6a181db4cc2e45c70af00 /tests
parent90a2dd65d681e28ebe3cca2d10d47405883e325d (diff)
downloadqtsvg-c9765d6ae3ffb7ad50f42457f709ad5eef60ba22.tar.gz
Fix compiler warning about unused function
Instead of providing an overload of diffIsSmallEnough for double and float each where one is always unused, make it a template. Pick-to: 6.0 Change-Id: I0b9ed29df844256ec77e990564201c5fe55bb59f Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
index 2f83301..e27ee51 100644
--- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
@@ -523,14 +523,17 @@ static qreal transformNorm(const QTransform &m)
+ m.m33() * m.m33());
}
-static bool diffIsSmallEnough(double diff, double norm)
+template<typename T>
+static inline bool diffIsSmallEnough(T diff, T norm)
{
- return diff <= 1e-12 * norm;
-}
-
-static inline bool diffIsSmallEnough(float diff, float norm)
-{
- return diff <= 1e-5 * norm;
+ static_assert(std::is_same_v<T, double> || std::is_same_v<T, float>);
+ T sigma = []{
+ if constexpr (std::is_same_v<T, double>)
+ return 1e-12;
+ else
+ return 1e-5;
+ }();
+ return diff <= sigma * norm;
}
static void compareTransforms(const QTransform &m1, const QTransform &m2)