diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-02-23 12:07:29 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-04-18 19:23:44 -0300 |
commit | 7ba76731ef70a54de841f5310f17cb48977c67d8 (patch) | |
tree | ed12816deb86c1257757c6115f2732aa11d1c887 /tests/auto/corelib/kernel/qdeadlinetimer | |
parent | b498e1ae3a3c6f188952f02a5ba14d092fbd168b (diff) |
QDeadlineTimer: use if constexpr instead of function specializations
You can't partially specialize a template function, so these
specializations for steady_clock only worked if the Duration parameter
was nanoseconds. This could have been solved with function overloads
instead, but I find the if constexpr code simpler to read.
Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17468bd73fc2fe24
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel/qdeadlinetimer')
-rw-r--r-- | tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp index 2627d6beca..ab8adfc75b 100644 --- a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp +++ b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp @@ -679,6 +679,14 @@ void tst_QDeadlineTimer::stdchrono() QCOMPARE_LT(deadline.deadline<steady_clock>(), (steady_clock::now() + 5ms * minResolution)); QCOMPARE_GT(deadline.deadline<system_clock>(), (system_clock::now() + 3ms * minResolution)); QCOMPARE_LT(deadline.deadline<system_clock>(), (system_clock::now() + 5ms * minResolution)); + QCOMPARE_GT((deadline.deadline<steady_clock, milliseconds>()), + steady_clock::now() + 3ms * minResolution); + QCOMPARE_LT((deadline.deadline<steady_clock, milliseconds>()), + steady_clock::now() + 5ms * minResolution); + QCOMPARE_GT((deadline.deadline<system_clock, milliseconds>()), + system_clock::now() + 3ms * minResolution); + QCOMPARE_LT((deadline.deadline<system_clock, milliseconds>()), + system_clock::now() + 5ms * minResolution); if (timerType == Qt::CoarseTimer) { QCOMPARE_GT(deadline, now + 3ms * minResolution); QCOMPARE_LT(deadline, now + 5ms * minResolution); |