swift
tests
misc
testslot
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
14
using namespace
swift::misc
;
15
16
namespace
MiscTest
17
{
19
class
CTestSlot
:
public
QObject
20
{
21
Q_OBJECT
22
23
private
slots:
25
void
slotBasics();
26
};
27
28
void
CTestSlot::slotBasics()
29
{
30
QObject *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
45
SWIFTTEST_APPLESS_MAIN
(
MiscTest::CTestSlot
);
46
47
#include "testslot.moc"
48
MiscTest::CTestSlot
CSlot tests.
Definition:
testslot.cpp:20
swift::misc::CSlot
Callable wrapper for a member function with function signature F.
Definition:
slot.h:62
swift::misc
Free functions in swift::misc.
Definition:
aircraftmatcher.h:22
slot.h
test.h
SWIFTTEST_APPLESS_MAIN
SWIFTTEST_APPLESS_MAIN(MiscTest::CTestSlot)
main
Generated on Mon Mar 24 2025 16:42:23 for swift by
1.9.1