author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
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 |
||
45 |
#include <qcoreapplication.h> |
|
46 |
#include <qdebug.h> |
|
47 |
#include <qsqlerror.h> |
|
48 |
||
49 |
||
50 |
//TESTED_CLASS= |
|
51 |
//TESTED_FILES= |
|
52 |
||
53 |
class tst_QSqlError : public QObject |
|
54 |
{ |
|
55 |
Q_OBJECT |
|
56 |
||
57 |
public: |
|
58 |
tst_QSqlError(); |
|
59 |
virtual ~tst_QSqlError(); |
|
60 |
||
61 |
private slots: |
|
62 |
void getSetCheck(); |
|
63 |
void construction(); |
|
64 |
}; |
|
65 |
||
66 |
tst_QSqlError::tst_QSqlError() |
|
67 |
{ |
|
68 |
} |
|
69 |
||
70 |
tst_QSqlError::~tst_QSqlError() |
|
71 |
{ |
|
72 |
} |
|
73 |
||
74 |
// Testing get/set functions |
|
75 |
void tst_QSqlError::getSetCheck() |
|
76 |
{ |
|
77 |
QSqlError obj1; |
|
78 |
// ErrorType QSqlError::type() |
|
79 |
// void QSqlError::setType(ErrorType) |
|
80 |
obj1.setType(QSqlError::ErrorType(QSqlError::NoError)); |
|
81 |
QCOMPARE(QSqlError::ErrorType(QSqlError::NoError), obj1.type()); |
|
82 |
obj1.setType(QSqlError::ErrorType(QSqlError::ConnectionError)); |
|
83 |
QCOMPARE(QSqlError::ErrorType(QSqlError::ConnectionError), obj1.type()); |
|
84 |
obj1.setType(QSqlError::ErrorType(QSqlError::StatementError)); |
|
85 |
QCOMPARE(QSqlError::ErrorType(QSqlError::StatementError), obj1.type()); |
|
86 |
obj1.setType(QSqlError::ErrorType(QSqlError::TransactionError)); |
|
87 |
QCOMPARE(QSqlError::ErrorType(QSqlError::TransactionError), obj1.type()); |
|
88 |
obj1.setType(QSqlError::ErrorType(QSqlError::UnknownError)); |
|
89 |
QCOMPARE(QSqlError::ErrorType(QSqlError::UnknownError), obj1.type()); |
|
90 |
||
91 |
// int QSqlError::number() |
|
92 |
// void QSqlError::setNumber(int) |
|
93 |
obj1.setNumber(0); |
|
94 |
QCOMPARE(0, obj1.number()); |
|
95 |
obj1.setNumber(INT_MIN); |
|
96 |
QCOMPARE(INT_MIN, obj1.number()); |
|
97 |
obj1.setNumber(INT_MAX); |
|
98 |
QCOMPARE(INT_MAX, obj1.number()); |
|
99 |
} |
|
100 |
||
101 |
void tst_QSqlError::construction() |
|
102 |
{ |
|
103 |
QSqlError obj1("drivertext", "databasetext", QSqlError::UnknownError, 123); |
|
104 |
QCOMPARE(obj1.driverText(), QString("drivertext")); |
|
105 |
QCOMPARE(obj1.databaseText(), QString("databasetext")); |
|
106 |
QCOMPARE(obj1.type(), QSqlError::UnknownError); |
|
107 |
QCOMPARE(obj1.number(), 123); |
|
108 |
obj1.isValid(); |
|
109 |
||
110 |
QSqlError obj2(obj1); |
|
111 |
QCOMPARE(obj2.driverText(), obj1.driverText()); |
|
112 |
QCOMPARE(obj2.databaseText(), obj1.databaseText()); |
|
113 |
QCOMPARE(obj2.type(), obj1.type()); |
|
114 |
QCOMPARE(obj2.number(), obj1.number()); |
|
115 |
QVERIFY(obj2.isValid()); |
|
116 |
||
117 |
QSqlError obj3 = obj2; |
|
118 |
QCOMPARE(obj3.driverText(), obj2.driverText()); |
|
119 |
QCOMPARE(obj3.databaseText(), obj2.databaseText()); |
|
120 |
QCOMPARE(obj3.type(), obj2.type()); |
|
121 |
QCOMPARE(obj3.number(), obj2.number()); |
|
122 |
QVERIFY(obj3.isValid()); |
|
123 |
||
124 |
QSqlError obj4; |
|
125 |
QVERIFY(!obj4.isValid()); |
|
126 |
} |
|
127 |
||
128 |
QTEST_MAIN(tst_QSqlError) |
|
129 |
#include "tst_qsqlerror.moc" |