swift
Loading...
Searching...
No Matches
testslot.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
7
8#include <QTest>
9
10#include "test.h"
11
12#include "misc/slot.h"
13
14using namespace swift::misc;
15
16namespace MiscTest
17{
19 class CTestSlot : public QObject
20 {
22
23 private slots:
25 void slotBasics();
26 };
27
28 void CTestSlot::slotBasics()
29 {
30 auto obj = new QObject(this);
31 CSlot<void(const QString &)> slot1 = { obj, [&](const QString &name) { obj->setObjectName(name); } };
32 QVERIFY2(slot1, "Slot has valid object and function - can be called.");
33
34 // KB 8/17 T125, CSlot can no longer be constructed with null object
35 // CSlot<void(const QString &)> slot2 = { static_cast<QObject*>(nullptr), &QObject::setObjectName };
36 // QVERIFY2(!slot2, "Slot has an invalid pointer - cannot be called.");
37
38 CSlot<void(const QString &)> slot3;
39 QVERIFY2(!slot3, "Slot has an invalid pointer and invalid function - cannot be called.");
40 }
41
42} // namespace MiscTest
43
46
47#include "testslot.moc"
48
CSlot tests.
Definition testslot.cpp:20
Callable wrapper for a member function with function signature F.
Definition slot.h:65
Free functions in swift::misc.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QVERIFY2(condition, message)
#define SWIFTTEST_APPLESS_MAIN(TestObject)
Implements a main() function that executes all tests in TestObject without instantiating a QApplicati...
Definition test.h:39