1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
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"