diff options
author | Marc Mutz <marc.mutz@qt.io> | 2024-01-31 16:17:40 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2024-02-07 12:15:09 +0000 |
commit | d4bb448cddce63e0c6a84a86020fa59dd32b2293 (patch) | |
tree | 785b84d33f9478c307184d8d5dba62193dfe33b0 /tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp | |
parent | fb226262e8b371372fdc66b832b9eab24741f70d (diff) |
QTest: allow passing chrono literal as QTRY_ timeout
By wrapping the use of the timeout value in QTRY_IMPL in a lambda that
feeds the user input through the std::chrono::milliseconds constructor
with std::chrono_literals in-scope, the macros continue to work with
raw integral values as well as chrono literals not finer than
millisecond granularity.
Port all higher-level macros to pass a chrono literal and port some
uses in tst_selftests.
[ChangeLog][QtTest] The QTRY_*_WITH_TIMEOUT macros now also accept
chrono literals (was: int milliseconds).
Fixes: QTBUG-121746
Change-Id: Ib38406fc005a0a2c4ae3fd009760f73ad8bed355
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp')
-rw-r--r-- | tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 5a8604e627..36e355c614 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -771,9 +771,9 @@ void tst_Cmptest::tryCompare() } { DeferredFlag c; - QTRY_COMPARE_WITH_TIMEOUT(c, DeferredFlag(), 300); + QTRY_COMPARE_WITH_TIMEOUT(c, DeferredFlag(), 300ms); QVERIFY(!c); // Instantly equal, so succeeded without delay. - QTRY_COMPARE_WITH_TIMEOUT(c, trueAlready, 200); + QTRY_COMPARE_WITH_TIMEOUT(c, trueAlready, 1s); qInfo("Should now time out and fail"); QTRY_COMPARE_WITH_TIMEOUT(c, DeferredFlag(), 200); } @@ -788,7 +788,7 @@ void tst_Cmptest::tryVerify() } { DeferredFlag c; - QTRY_VERIFY_WITH_TIMEOUT(!c, 300); + QTRY_VERIFY_WITH_TIMEOUT(!c, 300ms); QTRY_VERIFY_WITH_TIMEOUT(c, 200); qInfo("Should now time out and fail"); QTRY_VERIFY_WITH_TIMEOUT(!c, 200); @@ -804,7 +804,7 @@ void tst_Cmptest::tryVerify2() } { DeferredFlag c; - QTRY_VERIFY2_WITH_TIMEOUT(!c, "Failed to check before looping", 300); + QTRY_VERIFY2_WITH_TIMEOUT(!c, "Failed to check before looping", 300ms); QTRY_VERIFY2_WITH_TIMEOUT(c, "Failed to trigger single-shot", 200); QTRY_VERIFY2_WITH_TIMEOUT(!c, "Should time out and fail", 200); } |