Change copyrights from Nokia to Digia
[profile/ivi/qtxmlpatterns.git] / tests / auto / qxmlnodemodelindex / tst_qxmlnodemodelindex.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
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.
16 **
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.
24 **
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.
28 **
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.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42
43 #include <QtTest/QtTest>
44
45 #include <QXmlNodeModelIndex>
46
47 /*!
48  \class tst_QXmlNodeModelIndex
49  \internal
50  \since 4.4
51  \brief Tests class QXmlNodeModelIndex.
52
53  */
54 class tst_QXmlNodeModelIndex : public QObject
55 {
56     Q_OBJECT
57
58 private Q_SLOTS:
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;
66     void data() const;
67     void additionalData() const;
68     void isNull() const;
69     void model() const;
70     void withqHash() const;
71 };
72
73 void tst_QXmlNodeModelIndex::objectSize() const
74 {
75     /* We can't do an exact comparison, because some platforms do padding. */
76     QVERIFY(sizeof(QXmlNodeModelIndex) >= sizeof(QAbstractXmlNodeModel *) + sizeof(qint64) * 2);
77 }
78
79 void tst_QXmlNodeModelIndex::constCorrectness() const
80 {
81     const QXmlNodeModelIndex index;
82     /* All these functions should be const. */
83     index.internalPointer();
84     index.data();
85     index.additionalData();
86     index.isNull();
87     index.model();
88 }
89
90 void tst_QXmlNodeModelIndex::assignmentOperator() const
91 {
92     QXmlNodeModelIndex o1;
93     const QXmlNodeModelIndex o2;
94     o1 = o2;
95     // TODO
96 }
97
98 void tst_QXmlNodeModelIndex::equalnessOperator() const
99 {
100     QXmlNodeModelIndex o1;
101     const QXmlNodeModelIndex o2;
102     // TODO check const correctness
103     o1 == o2;
104 }
105
106 void tst_QXmlNodeModelIndex::inequalnessOperator() const
107 {
108     QXmlNodeModelIndex o1;
109     const QXmlNodeModelIndex o2;
110     // TODO check const correctness
111     o1 != o2;
112 }
113
114 void tst_QXmlNodeModelIndex::copyConstructor() const
115 {
116     /* Check that we can take a const reference. */
117     {
118         const QXmlNodeModelIndex index;
119         const QXmlNodeModelIndex copy(index);
120     }
121
122     /* Take a copy of a temporary. */
123     {
124         /* The extra paranthesis silences a warning on win32-msvc. */
125         const QXmlNodeModelIndex copy((QXmlNodeModelIndex()));
126     }
127 }
128
129 void tst_QXmlNodeModelIndex::internalPointer() const
130 {
131     /* Check default value. */
132     {
133         const QXmlNodeModelIndex index;
134         QCOMPARE(index.internalPointer(), static_cast<void *>(0));
135     }
136 }
137
138 void tst_QXmlNodeModelIndex::data() const
139 {
140     /* Check default value. */
141     {
142         const QXmlNodeModelIndex index;
143         QCOMPARE(index.data(), qint64(0));
144     }
145
146     // TODO check that the return value for data() is qint64.
147 }
148
149 void tst_QXmlNodeModelIndex::additionalData() const
150 {
151     /* Check default value. */
152     {
153         const QXmlNodeModelIndex index;
154         QCOMPARE(index.additionalData(), qint64(0));
155     }
156
157     // TODO check that the return value for data() is qint64.
158 }
159
160 void tst_QXmlNodeModelIndex::isNull() const
161 {
162     /* Check default value. */
163     {
164         const QXmlNodeModelIndex index;
165         QVERIFY(index.isNull());
166     }
167
168     /* Test default value on a temporary object. */
169     {
170         QVERIFY(QXmlNodeModelIndex().isNull());
171     }
172 }
173
174 void tst_QXmlNodeModelIndex::model() const
175 {
176     /* Check default value. */
177     {
178         const QXmlNodeModelIndex index;
179         QCOMPARE(index.model(), static_cast<const QAbstractXmlNodeModel *>(0));
180     }
181 }
182
183 void tst_QXmlNodeModelIndex::withqHash() const
184 {
185     QXmlNodeModelIndex null;
186     qHash(null);
187     //Do something which means operator== must be available.
188 }
189
190 QTEST_MAIN(tst_QXmlNodeModelIndex)
191
192 #include "tst_qxmlnodemodelindex.moc"