author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 3 | 41300fa6a67c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
||
43 |
#include <QtTest/QtTest> |
|
44 |
||
45 |
#ifdef QTEST_XMLPATTERNS |
|
46 |
||
47 |
#include <QXmlNodeModelIndex> |
|
48 |
||
49 |
/*! |
|
50 |
\class tst_QXmlNodeModelIndex |
|
51 |
\internal |
|
52 |
\since 4.4 |
|
53 |
\brief Tests class QXmlNodeModelIndex. |
|
54 |
||
55 |
*/ |
|
56 |
class tst_QXmlNodeModelIndex : public QObject |
|
57 |
{ |
|
58 |
Q_OBJECT |
|
59 |
||
60 |
private Q_SLOTS: |
|
61 |
void copyConstructor() const; |
|
62 |
void constCorrectness() const; |
|
63 |
void assignmentOperator() const; |
|
64 |
void equalnessOperator() const; |
|
65 |
void inequalnessOperator() const; |
|
66 |
void objectSize() const; |
|
67 |
void internalPointer() const; |
|
68 |
void data() const; |
|
69 |
void additionalData() const; |
|
70 |
void isNull() const; |
|
71 |
void model() const; |
|
72 |
void withqHash() const; |
|
73 |
}; |
|
74 |
||
75 |
void tst_QXmlNodeModelIndex::objectSize() const |
|
76 |
{ |
|
77 |
/* We can't do an exact comparison, because some platforms do padding. */ |
|
78 |
QVERIFY(sizeof(QXmlNodeModelIndex) >= sizeof(QAbstractXmlNodeModel *) + sizeof(qint64) * 2); |
|
79 |
} |
|
80 |
||
81 |
void tst_QXmlNodeModelIndex::constCorrectness() const |
|
82 |
{ |
|
83 |
const QXmlNodeModelIndex index; |
|
84 |
/* All these functions should be const. */ |
|
85 |
index.internalPointer(); |
|
86 |
index.data(); |
|
87 |
index.additionalData(); |
|
88 |
index.isNull(); |
|
89 |
index.model(); |
|
90 |
} |
|
91 |
||
92 |
void tst_QXmlNodeModelIndex::assignmentOperator() const |
|
93 |
{ |
|
94 |
QXmlNodeModelIndex o1; |
|
95 |
const QXmlNodeModelIndex o2; |
|
96 |
o1 = o2; |
|
97 |
// TODO |
|
98 |
} |
|
99 |
||
100 |
void tst_QXmlNodeModelIndex::equalnessOperator() const |
|
101 |
{ |
|
102 |
QXmlNodeModelIndex o1; |
|
103 |
const QXmlNodeModelIndex o2; |
|
104 |
// TODO check const correctness |
|
105 |
o1 == o2; |
|
106 |
} |
|
107 |
||
108 |
void tst_QXmlNodeModelIndex::inequalnessOperator() const |
|
109 |
{ |
|
110 |
QXmlNodeModelIndex o1; |
|
111 |
const QXmlNodeModelIndex o2; |
|
112 |
// TODO check const correctness |
|
113 |
o1 != o2; |
|
114 |
} |
|
115 |
||
116 |
void tst_QXmlNodeModelIndex::copyConstructor() const |
|
117 |
{ |
|
118 |
/* Check that we can take a const reference. */ |
|
119 |
{ |
|
120 |
const QXmlNodeModelIndex index; |
|
121 |
const QXmlNodeModelIndex copy(index); |
|
122 |
} |
|
123 |
||
124 |
/* Take a copy of a temporary. */ |
|
125 |
{ |
|
126 |
/* The extra paranthesis silences a warning on win32-msvc. */ |
|
127 |
const QXmlNodeModelIndex copy((QXmlNodeModelIndex())); |
|
128 |
} |
|
129 |
} |
|
130 |
||
131 |
void tst_QXmlNodeModelIndex::internalPointer() const |
|
132 |
{ |
|
133 |
/* Check default value. */ |
|
134 |
{ |
|
135 |
const QXmlNodeModelIndex index; |
|
136 |
QCOMPARE(index.internalPointer(), static_cast<void *>(0)); |
|
137 |
} |
|
138 |
} |
|
139 |
||
140 |
void tst_QXmlNodeModelIndex::data() const |
|
141 |
{ |
|
142 |
/* Check default value. */ |
|
143 |
{ |
|
144 |
const QXmlNodeModelIndex index; |
|
145 |
QCOMPARE(index.data(), qint64(0)); |
|
146 |
} |
|
147 |
||
148 |
// TODO check that the return value for data() is qint64. |
|
149 |
} |
|
150 |
||
151 |
void tst_QXmlNodeModelIndex::additionalData() const |
|
152 |
{ |
|
153 |
/* Check default value. */ |
|
154 |
{ |
|
155 |
const QXmlNodeModelIndex index; |
|
156 |
QCOMPARE(index.additionalData(), qint64(0)); |
|
157 |
} |
|
158 |
||
159 |
// TODO check that the return value for data() is qint64. |
|
160 |
} |
|
161 |
||
162 |
void tst_QXmlNodeModelIndex::isNull() const |
|
163 |
{ |
|
164 |
/* Check default value. */ |
|
165 |
{ |
|
166 |
const QXmlNodeModelIndex index; |
|
167 |
QVERIFY(index.isNull()); |
|
168 |
} |
|
169 |
||
170 |
/* Test default value on a temporary object. */ |
|
171 |
{ |
|
172 |
QVERIFY(QXmlNodeModelIndex().isNull()); |
|
173 |
} |
|
174 |
} |
|
175 |
||
176 |
void tst_QXmlNodeModelIndex::model() const |
|
177 |
{ |
|
178 |
/* Check default value. */ |
|
179 |
{ |
|
180 |
const QXmlNodeModelIndex index; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
QCOMPARE(index.model(), static_cast<const QAbstractXmlNodeModel *>(0)); |
0 | 182 |
} |
183 |
} |
|
184 |
||
185 |
void tst_QXmlNodeModelIndex::withqHash() const |
|
186 |
{ |
|
187 |
QXmlNodeModelIndex null; |
|
188 |
qHash(null); |
|
189 |
//Do something which means operator== must be available. |
|
190 |
} |
|
191 |
||
192 |
QTEST_MAIN(tst_QXmlNodeModelIndex) |
|
193 |
||
194 |
#include "tst_qxmlnodemodelindex.moc" |
|
195 |
#else //QTEST_XMLPATTERNS |
|
196 |
QTEST_NOOP_MAIN |
|
197 |
#endif |