1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
43 #include <QtTest/QtTest>
45 #include <QXmlNodeModelIndex>
48 \class tst_QXmlNodeModelIndex
51 \brief Tests class QXmlNodeModelIndex.
54 class tst_QXmlNodeModelIndex : public QObject
59 void copyConstructor() const;
60 void constCorrectness() const;
61 void assignmentOperator() const;
62 void equalnessOperator() const;
63 void inequalnessOperator() const;
64 void objectSize() const;
65 void internalPointer() const;
67 void additionalData() const;
70 void withqHash() const;
73 void tst_QXmlNodeModelIndex::objectSize() const
75 /* We can't do an exact comparison, because some platforms do padding. */
76 QVERIFY(sizeof(QXmlNodeModelIndex) >= sizeof(QAbstractXmlNodeModel *) + sizeof(qint64) * 2);
79 void tst_QXmlNodeModelIndex::constCorrectness() const
81 const QXmlNodeModelIndex index;
82 /* All these functions should be const. */
83 index.internalPointer();
85 index.additionalData();
90 void tst_QXmlNodeModelIndex::assignmentOperator() const
92 QXmlNodeModelIndex o1;
93 const QXmlNodeModelIndex o2;
98 void tst_QXmlNodeModelIndex::equalnessOperator() const
100 QXmlNodeModelIndex o1;
101 const QXmlNodeModelIndex o2;
102 // TODO check const correctness
106 void tst_QXmlNodeModelIndex::inequalnessOperator() const
108 QXmlNodeModelIndex o1;
109 const QXmlNodeModelIndex o2;
110 // TODO check const correctness
114 void tst_QXmlNodeModelIndex::copyConstructor() const
116 /* Check that we can take a const reference. */
118 const QXmlNodeModelIndex index;
119 const QXmlNodeModelIndex copy(index);
122 /* Take a copy of a temporary. */
124 /* The extra paranthesis silences a warning on win32-msvc. */
125 const QXmlNodeModelIndex copy((QXmlNodeModelIndex()));
129 void tst_QXmlNodeModelIndex::internalPointer() const
131 /* Check default value. */
133 const QXmlNodeModelIndex index;
134 QCOMPARE(index.internalPointer(), static_cast<void *>(0));
138 void tst_QXmlNodeModelIndex::data() const
140 /* Check default value. */
142 const QXmlNodeModelIndex index;
143 QCOMPARE(index.data(), qint64(0));
146 // TODO check that the return value for data() is qint64.
149 void tst_QXmlNodeModelIndex::additionalData() const
151 /* Check default value. */
153 const QXmlNodeModelIndex index;
154 QCOMPARE(index.additionalData(), qint64(0));
157 // TODO check that the return value for data() is qint64.
160 void tst_QXmlNodeModelIndex::isNull() const
162 /* Check default value. */
164 const QXmlNodeModelIndex index;
165 QVERIFY(index.isNull());
168 /* Test default value on a temporary object. */
170 QVERIFY(QXmlNodeModelIndex().isNull());
174 void tst_QXmlNodeModelIndex::model() const
176 /* Check default value. */
178 const QXmlNodeModelIndex index;
179 QCOMPARE(index.model(), static_cast<const QAbstractXmlNodeModel *>(0));
183 void tst_QXmlNodeModelIndex::withqHash() const
185 QXmlNodeModelIndex null;
187 //Do something which means operator== must be available.
190 QTEST_MAIN(tst_QXmlNodeModelIndex)
192 #include "tst_qxmlnodemodelindex.moc"