author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 15 Mar 2010 12:43:09 +0200 | |
branch | RCL_3 |
changeset 6 | dee5afe5301f |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
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 |
#include <QList> |
|
45 |
||
46 |
//TESTED_CLASS=QList |
|
47 |
//TESTED_FILES=corelib/tools/qlist.h corelib/tools/qlist.cpp |
|
48 |
||
49 |
/*! |
|
50 |
\class tst_QVector |
|
51 |
\internal |
|
52 |
\since 4.5 |
|
53 |
\brief Test Qt's class QList. |
|
54 |
*/ |
|
55 |
class tst_QList : public QObject |
|
56 |
{ |
|
57 |
Q_OBJECT |
|
58 |
||
59 |
private slots: |
|
60 |
void length() const; |
|
61 |
void lengthSignature() const; |
|
62 |
void append() const; |
|
63 |
}; |
|
64 |
||
65 |
void tst_QList::length() const |
|
66 |
{ |
|
67 |
/* Empty list. */ |
|
68 |
{ |
|
69 |
const QList<int> list; |
|
70 |
QCOMPARE(list.length(), 0); |
|
71 |
} |
|
72 |
||
73 |
/* One entry. */ |
|
74 |
{ |
|
75 |
QList<int> list; |
|
76 |
list.append(0); |
|
77 |
QCOMPARE(list.length(), 1); |
|
78 |
} |
|
79 |
||
80 |
/* Two entries. */ |
|
81 |
{ |
|
82 |
QList<int> list; |
|
83 |
list.append(0); |
|
84 |
list.append(1); |
|
85 |
QCOMPARE(list.length(), 2); |
|
86 |
} |
|
87 |
||
88 |
/* Three entries. */ |
|
89 |
{ |
|
90 |
QList<int> list; |
|
91 |
list.append(0); |
|
92 |
list.append(0); |
|
93 |
list.append(0); |
|
94 |
QCOMPARE(list.length(), 3); |
|
95 |
} |
|
96 |
} |
|
97 |
||
98 |
void tst_QList::lengthSignature() const |
|
99 |
{ |
|
100 |
/* Constness. */ |
|
101 |
{ |
|
102 |
const QList<int> list; |
|
103 |
/* The function should be const. */ |
|
104 |
list.length(); |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
void tst_QList::append() const |
|
109 |
{ |
|
110 |
/* test append(const QList<T> &) function */ |
|
111 |
QString one("one"); |
|
112 |
QString two("two"); |
|
113 |
QString three("three"); |
|
114 |
QString four("four"); |
|
115 |
QList<QString> list1; |
|
116 |
QList<QString> list2; |
|
117 |
QList<QString> listTotal; |
|
118 |
list1.append(one); |
|
119 |
list1.append(two); |
|
120 |
list2.append(three); |
|
121 |
list2.append(four); |
|
122 |
list1.append(list2); |
|
123 |
qDebug() << list1; |
|
124 |
listTotal.append(one); |
|
125 |
listTotal.append(two); |
|
126 |
listTotal.append(three); |
|
127 |
listTotal.append(four); |
|
128 |
QCOMPARE(list1, listTotal); |
|
129 |
||
130 |
} |
|
131 |
||
132 |
QTEST_APPLESS_MAIN(tst_QList) |
|
133 |
#include "tst_qlist.moc" |