1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the test suite of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
43 #include <QtTest/QtTest>
45 #ifdef QTEST_XMLPATTERNS
47 #include <QXmlNodeModelIndex>
50 \class tst_QXmlNodeModelIndex
53 \brief Tests class QXmlNodeModelIndex.
56 class tst_QXmlNodeModelIndex : public QObject
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;
69 void additionalData() const;
72 void withqHash() const;
75 void tst_QXmlNodeModelIndex::objectSize() const
77 /* We can't do an exact comparison, because some platforms do padding. */
78 QVERIFY(sizeof(QXmlNodeModelIndex) >= sizeof(QAbstractXmlNodeModel *) + sizeof(qint64) * 2);
81 void tst_QXmlNodeModelIndex::constCorrectness() const
83 const QXmlNodeModelIndex index;
84 /* All these functions should be const. */
85 index.internalPointer();
87 index.additionalData();
92 void tst_QXmlNodeModelIndex::assignmentOperator() const
94 QXmlNodeModelIndex o1;
95 const QXmlNodeModelIndex o2;
100 void tst_QXmlNodeModelIndex::equalnessOperator() const
102 QXmlNodeModelIndex o1;
103 const QXmlNodeModelIndex o2;
104 // TODO check const correctness
108 void tst_QXmlNodeModelIndex::inequalnessOperator() const
110 QXmlNodeModelIndex o1;
111 const QXmlNodeModelIndex o2;
112 // TODO check const correctness
116 void tst_QXmlNodeModelIndex::copyConstructor() const
118 /* Check that we can take a const reference. */
120 const QXmlNodeModelIndex index;
121 const QXmlNodeModelIndex copy(index);
124 /* Take a copy of a temporary. */
126 /* The extra paranthesis silences a warning on win32-msvc. */
127 const QXmlNodeModelIndex copy((QXmlNodeModelIndex()));
131 void tst_QXmlNodeModelIndex::internalPointer() const
133 /* Check default value. */
135 const QXmlNodeModelIndex index;
136 QCOMPARE(index.internalPointer(), static_cast<void *>(0));
140 void tst_QXmlNodeModelIndex::data() const
142 /* Check default value. */
144 const QXmlNodeModelIndex index;
145 QCOMPARE(index.data(), qint64(0));
148 // TODO check that the return value for data() is qint64.
151 void tst_QXmlNodeModelIndex::additionalData() const
153 /* Check default value. */
155 const QXmlNodeModelIndex index;
156 QCOMPARE(index.additionalData(), qint64(0));
159 // TODO check that the return value for data() is qint64.
162 void tst_QXmlNodeModelIndex::isNull() const
164 /* Check default value. */
166 const QXmlNodeModelIndex index;
167 QVERIFY(index.isNull());
170 /* Test default value on a temporary object. */
172 QVERIFY(QXmlNodeModelIndex().isNull());
176 void tst_QXmlNodeModelIndex::model() const
178 /* Check default value. */
180 const QXmlNodeModelIndex index;
181 QCOMPARE(index.model(), static_cast<const QAbstractXmlNodeModel *>(0));
185 void tst_QXmlNodeModelIndex::withqHash() const
187 QXmlNodeModelIndex null;
189 //Do something which means operator== must be available.
192 QTEST_MAIN(tst_QXmlNodeModelIndex)
194 #include "tst_qxmlnodemodelindex.moc"
195 #else //QTEST_XMLPATTERNS