Debian Codegraph @

tests/auto/core/handle/tst_handle.cpp

raw symbols SCIP
1 // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 #include <QtTest/QTest>
5 #include <Qt3DCore/private/qhandle_p.h>
6 #include <Qt3DCore/private/qresourcemanager_p.h>
7
8 class tst_Handle : public QObject
9 {
10 Q_OBJECT
11 public:
12 tst_Handle() {}
13 ~tst_Handle() {}
14
15 private slots:
16 void defaultConstruction();
17 void construction();
18 void copyConstruction();
19 void assignment();
20 void equality();
21 void inequality();
22 };
23
24 class SimpleResource
25 {
26 public:
27 SimpleResource()
28 : m_value(0)
29 {}
30
31 int m_value;
32 };
33
34 typedef Qt3DCore::QHandle<SimpleResource> Handle;
35 typedef Qt3DCore::QHandleData<SimpleResource> HandleData;
36
37 void tst_Handle::defaultConstruction()
38 {
39 Handle h;
40 QVERIFY(h.isNull() == true);
41 QVERIFY(h.handle() == 0);
42 }
43
44 void tst_Handle::construction()
45 {
46 HandleData d;
47 Handle h(&d);
48 QVERIFY(h.isNull() == false);
49 qDebug() << h;
50 QVERIFY(h.handle() == reinterpret_cast<quintptr>(&d));
51 }
52
53 void tst_Handle::copyConstruction()
54 {
55 HandleData d;
56 Handle h(&d);
57 Handle h2(h);
58 QVERIFY(h2.isNull() == false);
59 QVERIFY(h2.handle() == h.handle());
60 }
61
62 void tst_Handle::assignment()
63 {
64 HandleData d;
65 Handle h(&d);
66 Handle h2;
67 h2 = h;
68 QVERIFY(h2.isNull() == false);
69 QVERIFY(h2.handle() == h.handle());
70 }
71
72 void tst_Handle::equality()
73 {
74 HandleData d;
75 Handle h1(&d);
76 Handle h2(&d);
77 QVERIFY(h1.isNull() == false);
78 QVERIFY(h1 == h2);
79 }
80
81 void tst_Handle::inequality()
82 {
83 HandleData d1;
84 HandleData d2;
85 Handle h1(&d1);
86 Handle h2(&d2);
87 QVERIFY(h1.isNull() == false);
88 QVERIFY(h1 != h2);
89 }
90
91 QTEST_APPLESS_MAIN(tst_Handle)
92
93 #include "tst_handle.moc"