From 61e0671681d61bcd643b5f950e1308f4d8430fea Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 5 May 2023 13:06:25 +0200 Subject: QSlotObject helpers: add testcoverage for std::function Change-Id: I503c627c77eaab7d2e3456f23b55fdfcdc94c0ea Reviewed-by: Ville Voutilainen --- tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 3d353a4044..b8f808ddfe 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -8373,7 +8373,7 @@ public: void callbackInt(int) {} int returnInt() const { return 0; } - static void staticCallback0() {} + static int staticCallback0() { return 0; } static void staticCallback1(const QString &) {} using Prototype0 = int(*)(); @@ -8488,6 +8488,11 @@ void tst_QObject::asyncCallbackHelper() static_assert(compiles(freeFunctionVariant)); + std::function stdFunction0(&AsyncCaller::staticCallback0); + std::function stdFunction1(&AsyncCaller::staticCallback1); + static_assert(compiles(stdFunction0)); + static_assert(compiles(stdFunction1)); + AsyncCaller caller; // with context QVERIFY(caller.callMe0(&caller, &AsyncCaller::callback0)); @@ -8496,23 +8501,27 @@ void tst_QObject::asyncCallbackHelper() QVERIFY(caller.callMe0(&caller, lambda0)); QVERIFY(caller.callMe0(&caller, freeFunction0)); QVERIFY(caller.callMe0(&caller, std::move(moveOnlyLambda))); + QVERIFY(caller.callMe0(&caller, stdFunction0)); QVERIFY(caller.callMe1(&caller, &AsyncCaller::callback1)); QVERIFY(caller.callMe1(&caller, &AsyncCaller::staticCallback1)); QVERIFY(caller.callMe1(&caller, lambda1)); QVERIFY(caller.callMe1(&caller, freeFunction1)); QVERIFY(caller.callMe1(&caller, constLambda)); + QVERIFY(caller.callMe1(&caller, stdFunction1)); // without context QVERIFY(caller.callMe0(&AsyncCaller::staticCallback0)); QVERIFY(caller.callMe0(lambda0)); QVERIFY(caller.callMe0(freeFunction0)); + QVERIFY(caller.callMe0(stdFunction0)); QVERIFY(caller.callMe1(&AsyncCaller::staticCallback1)); QVERIFY(caller.callMe1(lambda1)); QVERIFY(caller.callMe1(constLambda)); QVERIFY(caller.callMe1(std::move(moveOnlyLambda1))); QVERIFY(caller.callMe1(freeFunction1)); + QVERIFY(caller.callMe1(stdFunction1)); static const char *expectedPayload = "Hello World!"; { -- cgit v1.2.1