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 |
||
46 |
#include <qvalidator.h> |
|
47 |
||
48 |
class tst_QDoubleValidator : public QObject |
|
49 |
{ |
|
50 |
Q_OBJECT |
|
51 |
private slots: |
|
52 |
void validate_data(); |
|
53 |
void validate(); |
|
54 |
void validateThouSep_data(); |
|
55 |
void validateThouSep(); |
|
56 |
void validateIntEquiv_data(); |
|
57 |
void validateIntEquiv(); |
|
58 |
}; |
|
59 |
||
60 |
Q_DECLARE_METATYPE(QValidator::State); |
|
61 |
#define INV QValidator::Invalid |
|
62 |
#define ITM QValidator::Intermediate |
|
63 |
#define ACC QValidator::Acceptable |
|
64 |
||
65 |
void tst_QDoubleValidator::validateThouSep_data() |
|
66 |
{ |
|
67 |
QTest::addColumn<QString>("localeName"); |
|
68 |
QTest::addColumn<QString>("value"); |
|
69 |
QTest::addColumn<QValidator::State>("result"); |
|
70 |
||
71 |
QTest::newRow("1,000C") << "C" << QString("1,000") << INV; |
|
72 |
QTest::newRow("1.000C") << "C" << QString("1.000") << ACC; |
|
73 |
||
74 |
QTest::newRow("1,000de") << "de" << QString("1,000") << ACC; |
|
75 |
QTest::newRow("1.000de") << "de" << QString("1.000") << ACC; |
|
76 |
||
77 |
QTest::newRow(".C") << "C" << QString(".") << ITM; |
|
78 |
QTest::newRow(".de") << "de" << QString(".") << ITM; |
|
79 |
QTest::newRow(",C") << "C" << QString(",") << INV; |
|
80 |
QTest::newRow(",de") << "de" << QString(",") << ITM; |
|
81 |
} |
|
82 |
||
83 |
void tst_QDoubleValidator::validateThouSep() |
|
84 |
{ |
|
85 |
QFETCH(QString, localeName); |
|
86 |
QFETCH(QString, value); |
|
87 |
QFETCH(QValidator::State, result); |
|
88 |
int dummy = 0; |
|
89 |
||
90 |
QDoubleValidator iv(-10000, 10000, 3, 0); |
|
91 |
iv.setNotation(QDoubleValidator::ScientificNotation); |
|
92 |
iv.setLocale(QLocale(localeName)); |
|
93 |
||
94 |
QCOMPARE(iv.validate(value, dummy), result); |
|
95 |
} |
|
96 |
||
97 |
void tst_QDoubleValidator::validate_data() |
|
98 |
{ |
|
99 |
QTest::addColumn<QString>("localeName"); |
|
100 |
QTest::addColumn<double>("minimum"); |
|
101 |
QTest::addColumn<double>("maximum"); |
|
102 |
QTest::addColumn<int>("decimals"); |
|
103 |
QTest::addColumn<QString>("value"); |
|
104 |
QTest::addColumn<QValidator::State>("scientific_state"); |
|
105 |
QTest::addColumn<QValidator::State>("standard_state"); |
|
106 |
||
107 |
QTest::newRow("data0") << "C" << 0.0 << 100.0 << 1 << QString("50.0") << ACC << ACC; |
|
108 |
QTest::newRow("data1") << "C" << 00.0 << 100.0 << 1 << QString("500.0") << ITM << ITM; |
|
109 |
QTest::newRow("data1a") << "C" << 00.0 << 100.0 << 1 << QString("5001.0") << ITM << INV; |
|
110 |
QTest::newRow("data2") << "C" << 00.0 << 100.0 << 1 << QString("-35.0") << INV << INV; |
|
111 |
QTest::newRow("data3") << "C" << 00.0 << 100.0 << 1 << QString("a") << INV << INV; |
|
112 |
QTest::newRow("data4") << "C" << 0.0 << 100.0 << 1 << QString("-") << INV << INV; |
|
113 |
QTest::newRow("data5") << "C" << 0.0 << 100.0 << 1 << QString("100.0") << ACC << ACC; |
|
114 |
QTest::newRow("data6") << "C" << -100.0 << 100.0 << 1 << QString("-") << ITM << ITM; |
|
115 |
QTest::newRow("data7") << "C" << -100.0 << 100.0 << 1 << QString("-500.0") << ITM << ITM; |
|
116 |
QTest::newRow("data8") << "C" << -100.0 << 100.0 << 1 << QString("-100") << ACC << ACC; |
|
117 |
QTest::newRow("data9") << "C" << -100.0 << -10.0 << 1 << QString("10") << ITM << ITM; |
|
118 |
QTest::newRow("data10") << "C" << 0.3 << 0.5 << 5 << QString("0.34567") << ACC << ACC; |
|
119 |
QTest::newRow("data11") << "C" << -0.3 << -0.5 << 5 << QString("-0.345678") << INV << INV; |
|
120 |
QTest::newRow("data12") << "C" << -0.32 << 0.32 << 1 << QString("0") << ACC << ACC; |
|
121 |
QTest::newRow("data13") << "C" << 0.0 << 100.0 << 1 << QString("3456a") << INV << INV; |
|
122 |
QTest::newRow("data14") << "C" << -100.0 << 100.0 << 1 << QString("-3456a") << INV << INV; |
|
123 |
QTest::newRow("data15") << "C" << -100.0 << 100.0 << 1 << QString("a-3456") << INV << INV; |
|
124 |
QTest::newRow("data16") << "C" << -100.0 << 100.0 << 1 << QString("a-3456a") << INV << INV; |
|
125 |
QTest::newRow("data17") << "C" << 1229.0 << 1231.0 << 0 << QString("123e") << ITM << INV; |
|
126 |
QTest::newRow("data18") << "C" << 1229.0 << 1231.0 << 0 << QString("123e+") << ITM << INV; |
|
127 |
QTest::newRow("data19") << "C" << 1229.0 << 1231.0 << 0 << QString("123e+1") << ACC << INV; |
|
128 |
QTest::newRow("data20") << "C" << 12290.0 << 12310.0 << 0 << QString("123e+2") << ACC << INV; |
|
129 |
QTest::newRow("data21") << "C" << 12.290 << 12.310 << 2 << QString("123e-") << ITM << INV; |
|
130 |
QTest::newRow("data22") << "C" << 12.290 << 12.310 << 2 << QString("123e-1") << ACC << INV; |
|
131 |
QTest::newRow("data23") << "C" << 1.2290 << 1.2310 << 3 << QString("123e-2") << ACC << INV; |
|
132 |
QTest::newRow("data24") << "C" << 1229.0 << 1231.0 << 0 << QString("123E") << ITM << INV; |
|
133 |
QTest::newRow("data25") << "C" << 1229.0 << 1231.0 << 0 << QString("123E+") << ITM << INV; |
|
134 |
QTest::newRow("data26") << "C" << 1229.0 << 1231.0 << 0 << QString("123E+1") << ACC << INV; |
|
135 |
QTest::newRow("data27") << "C" << 12290.0 << 12310.0 << 0 << QString("123E+2") << ACC << INV; |
|
136 |
QTest::newRow("data28") << "C" << 12.290 << 12.310 << 2 << QString("123E-") << ITM << INV; |
|
137 |
QTest::newRow("data29") << "C" << 12.290 << 12.310 << 2 << QString("123E-1") << ACC << INV; |
|
138 |
QTest::newRow("data30") << "C" << 1.2290 << 1.2310 << 3 << QString("123E-2") << ACC << INV; |
|
139 |
QTest::newRow("data31") << "C" << 1.2290 << 1.2310 << 3 << QString("e") << ITM << INV; |
|
140 |
QTest::newRow("data32") << "C" << 1.2290 << 1.2310 << 3 << QString("e+") << ITM << INV; |
|
141 |
QTest::newRow("data33") << "C" << 1.2290 << 1.2310 << 3 << QString("e+1") << ITM << INV; |
|
142 |
QTest::newRow("data34") << "C" << 1.2290 << 1.2310 << 3 << QString("e-") << ITM << INV; |
|
143 |
QTest::newRow("data35") << "C" << 1.2290 << 1.2310 << 3 << QString("e-1") << ITM << INV; |
|
144 |
QTest::newRow("data36") << "C" << 1.2290 << 1.2310 << 3 << QString("E") << ITM << INV; |
|
145 |
QTest::newRow("data37") << "C" << 1.2290 << 1.2310 << 3 << QString("E+") << ITM << INV; |
|
146 |
QTest::newRow("data38") << "C" << 1.2290 << 1.2310 << 3 << QString("E+1") << ITM << INV; |
|
147 |
QTest::newRow("data39") << "C" << 1.2290 << 1.2310 << 3 << QString("E-") << ITM << INV; |
|
148 |
QTest::newRow("data40") << "C" << 1.2290 << 1.2310 << 3 << QString("E-1") << ITM << INV; |
|
149 |
QTest::newRow("data41") << "C" << -100.0 << 100.0 << 0 << QString("10e") << ITM << INV; |
|
150 |
QTest::newRow("data42") << "C" << -100.0 << 100.0 << 0 << QString("10e+") << ITM << INV; |
|
151 |
QTest::newRow("data43") << "C" << 0.01 << 0.09 << 2 << QString("0") << ITM << ITM; |
|
152 |
QTest::newRow("data44") << "C" << 0.0 << 10.0 << 1 << QString("11") << ITM << ITM; |
|
153 |
QTest::newRow("data45") << "C" << 0.0 << 10.0 << 2 << QString("11") << ITM << ITM; |
|
154 |
QTest::newRow("data46") << "C" << 0.0 << 100.0 << 0 << QString("0.") << ACC << ACC; |
|
155 |
QTest::newRow("data47") << "C" << 0.0 << 100.0 << 0 << QString("0.0") << INV << INV; |
|
156 |
QTest::newRow("data48") << "C" << 0.0 << 100.0 << 1 << QString("0.0") << ACC << ACC; |
|
157 |
QTest::newRow("data49") << "C" << 0.0 << 100.0 << 0 << QString(".") << ITM << ITM; |
|
158 |
QTest::newRow("data50") << "C" << 0.0 << 100.0 << 1 << QString(".") << ITM << ITM; |
|
159 |
||
160 |
QTest::newRow("data_de0") << "de" << 0.0 << 100.0 << 1 << QString("50,0") << ACC << ACC; |
|
161 |
QTest::newRow("data_de1") << "de" << 00.0 << 100.0 << 1 << QString("500,0") << ITM << ITM; |
|
162 |
QTest::newRow("data_de1a") << "de" << 00.0 << 100.0 << 1 << QString("5001,0") << ITM << INV; |
|
163 |
QTest::newRow("data_de0C") << "de" << 0.0 << 100.0 << 1 << QString("50.0") << ACC << ACC; |
|
164 |
QTest::newRow("data_de1C") << "de" << 00.0 << 100.0 << 1 << QString("500.0") << ITM << ITM; |
|
165 |
QTest::newRow("data_de1aC") << "de" << 00.0 << 100.0 << 1 << QString("5001.0") << ITM << INV; |
|
166 |
QTest::newRow("data_de2") << "de" << 00.0 << 100.0 << 1 << QString("-35,0") << INV << INV; |
|
167 |
QTest::newRow("data_de3") << "de" << 00.0 << 100.0 << 1 << QString("a") << INV << INV; |
|
168 |
QTest::newRow("data_de4") << "de" << 0.0 << 100.0 << 1 << QString("-") << INV << INV; |
|
169 |
QTest::newRow("data_de5") << "de" << 0.0 << 100.0 << 1 << QString("100,0") << ACC << ACC; |
|
170 |
QTest::newRow("data_de6") << "de" << -100.0 << 100.0 << 1 << QString("-") << ITM << ITM; |
|
171 |
QTest::newRow("data_de7") << "de" << -100.0 << 100.0 << 1 << QString("-500,0") << ITM << ITM; |
|
172 |
QTest::newRow("data_de8") << "de" << -100.0 << 100.0 << 1 << QString("-100") << ACC << ACC; |
|
173 |
QTest::newRow("data_de9") << "de" << -100.0 << -10.0 << 1 << QString("10") << ITM << ITM; |
|
174 |
QTest::newRow("data_de10") << "de" << 0.3 << 0.5 << 5 << QString("0,34567") << ACC << ACC; |
|
175 |
QTest::newRow("data_de11") << "de" << -0.3 << -0.5 << 5 << QString("-0,345678") << INV << INV; |
|
176 |
QTest::newRow("data_de12") << "de" << -0.32 << 0.32 << 1 << QString("0") << ACC << ACC; |
|
177 |
QTest::newRow("data_de13") << "de" << 0.0 << 100.0 << 1 << QString("3456a") << INV << INV; |
|
178 |
QTest::newRow("data_de14") << "de" << -100.0 << 100.0 << 1 << QString("-3456a") << INV << INV; |
|
179 |
QTest::newRow("data_de15") << "de" << -100.0 << 100.0 << 1 << QString("a-3456") << INV << INV; |
|
180 |
QTest::newRow("data_de16") << "de" << -100.0 << 100.0 << 1 << QString("a-3456a") << INV << INV; |
|
181 |
QTest::newRow("data_de17") << "de" << 1229.0 << 1231.0 << 0 << QString("123e") << ITM << INV; |
|
182 |
QTest::newRow("data_de18") << "de" << 1229.0 << 1231.0 << 0 << QString("123e+") << ITM << INV; |
|
183 |
QTest::newRow("data_de19") << "de" << 1229.0 << 1231.0 << 0 << QString("123e+1") << ACC << INV; |
|
184 |
QTest::newRow("data_de20") << "de" << 12290.0 << 12310.0 << 0 << QString("123e+2") << ACC << INV; |
|
185 |
QTest::newRow("data_de21") << "de" << 12.290 << 12.310 << 2 << QString("123e-") << ITM << INV; |
|
186 |
QTest::newRow("data_de22") << "de" << 12.290 << 12.310 << 2 << QString("123e-1") << ACC << INV; |
|
187 |
QTest::newRow("data_de23") << "de" << 1.2290 << 1.2310 << 3 << QString("123e-2") << ACC << INV; |
|
188 |
QTest::newRow("data_de24") << "de" << 1229.0 << 1231.0 << 0 << QString("123E") << ITM << INV; |
|
189 |
QTest::newRow("data_de25") << "de" << 1229.0 << 1231.0 << 0 << QString("123E+") << ITM << INV; |
|
190 |
QTest::newRow("data_de26") << "de" << 1229.0 << 1231.0 << 0 << QString("123E+1") << ACC << INV; |
|
191 |
QTest::newRow("data_de27") << "de" << 12290.0 << 12310.0 << 0 << QString("123E+2") << ACC << INV; |
|
192 |
QTest::newRow("data_de28") << "de" << 12.290 << 12.310 << 2 << QString("123E-") << ITM << INV; |
|
193 |
QTest::newRow("data_de29") << "de" << 12.290 << 12.310 << 2 << QString("123E-1") << ACC << INV; |
|
194 |
QTest::newRow("data_de30") << "de" << 1.2290 << 1.2310 << 3 << QString("123E-2") << ACC << INV; |
|
195 |
QTest::newRow("data_de31") << "de" << 1.2290 << 1.2310 << 3 << QString("e") << ITM << INV; |
|
196 |
QTest::newRow("data_de32") << "de" << 1.2290 << 1.2310 << 3 << QString("e+") << ITM << INV; |
|
197 |
QTest::newRow("data_de33") << "de" << 1.2290 << 1.2310 << 3 << QString("e+1") << ITM << INV; |
|
198 |
QTest::newRow("data_de34") << "de" << 1.2290 << 1.2310 << 3 << QString("e-") << ITM << INV; |
|
199 |
QTest::newRow("data_de35") << "de" << 1.2290 << 1.2310 << 3 << QString("e-1") << ITM << INV; |
|
200 |
QTest::newRow("data_de36") << "de" << 1.2290 << 1.2310 << 3 << QString("E") << ITM << INV; |
|
201 |
QTest::newRow("data_de37") << "de" << 1.2290 << 1.2310 << 3 << QString("E+") << ITM << INV; |
|
202 |
QTest::newRow("data_de38") << "de" << 1.2290 << 1.2310 << 3 << QString("E+1") << ITM << INV; |
|
203 |
QTest::newRow("data_de39") << "de" << 1.2290 << 1.2310 << 3 << QString("E-") << ITM << INV; |
|
204 |
QTest::newRow("data_de40") << "de" << 1.2290 << 1.2310 << 3 << QString("E-1") << ITM << INV; |
|
205 |
QTest::newRow("data_de41") << "de" << -100.0 << 100.0 << 0 << QString("10e") << ITM << INV; |
|
206 |
QTest::newRow("data_de42") << "de" << -100.0 << 100.0 << 0 << QString("10e+") << ITM << INV; |
|
207 |
QTest::newRow("data_de43") << "de" << 0.01 << 0.09 << 2 << QString("0") << ITM << ITM; |
|
208 |
QTest::newRow("data_de44") << "de" << 0.0 << 10.0 << 1 << QString("11") << ITM << ITM; |
|
209 |
QTest::newRow("data_de45") << "de" << 0.0 << 10.0 << 2 << QString("11") << ITM << ITM; |
|
210 |
||
211 |
QString arabicNum; |
|
212 |
arabicNum += QChar(1633); // "18.4" in arabic |
|
213 |
arabicNum += QChar(1640); |
|
214 |
arabicNum += QChar(1643); |
|
215 |
arabicNum += QChar(1636); |
|
216 |
QTest::newRow("arabic") << "ar" << 0.0 << 20.0 << 2 << arabicNum << ACC << ACC; |
|
217 |
} |
|
218 |
||
219 |
void tst_QDoubleValidator::validate() |
|
220 |
{ |
|
221 |
QFETCH(QString, localeName); |
|
222 |
QFETCH(double, minimum); |
|
223 |
QFETCH(double, maximum); |
|
224 |
QFETCH(int, decimals); |
|
225 |
QFETCH(QString, value); |
|
226 |
QFETCH(QValidator::State, scientific_state); |
|
227 |
QFETCH(QValidator::State, standard_state); |
|
228 |
||
229 |
QLocale::setDefault(QLocale(localeName)); |
|
230 |
||
231 |
QDoubleValidator dv(minimum, maximum, decimals, 0); |
|
232 |
int dummy; |
|
233 |
QCOMPARE((int)dv.validate(value, dummy), (int)scientific_state); |
|
234 |
dv.setNotation(QDoubleValidator::StandardNotation); |
|
235 |
QCOMPARE((int)dv.validate(value, dummy), (int)standard_state); |
|
236 |
} |
|
237 |
||
238 |
void tst_QDoubleValidator::validateIntEquiv_data() |
|
239 |
{ |
|
240 |
QTest::addColumn<double>("minimum"); |
|
241 |
QTest::addColumn<double>("maximum"); |
|
242 |
QTest::addColumn<QString>("input"); |
|
243 |
QTest::addColumn<QValidator::State>("state"); |
|
244 |
||
245 |
QTest::newRow("1.1") << 0.0 << 10.0 << QString("") << ITM; |
|
246 |
QTest::newRow("1.2") << 10.0 << 0.0 << QString("") << ITM; |
|
247 |
||
248 |
QTest::newRow("2.1") << 0.0 << 10.0 << QString("-") << INV; |
|
249 |
QTest::newRow("2.2") << 0.0 << 10.0 << QString("-0") << INV; |
|
250 |
QTest::newRow("2.3") << -10.0 << -1.0 << QString("+") << INV; |
|
251 |
QTest::newRow("2.4") << -10.0 << 10.0 << QString("-") << ITM; |
|
252 |
QTest::newRow("2.5") << -10.0 << 10.0 << QString("+") << ITM; |
|
253 |
QTest::newRow("2.5a") << -10.0 << -9.0 << QString("+") << INV; |
|
254 |
QTest::newRow("2.6") << -10.0 << 10.0 << QString("+0") << ACC; |
|
255 |
QTest::newRow("2.7") << -10.0 << 10.0 << QString("+1") << ACC; |
|
256 |
QTest::newRow("2.8") << -10.0 << 10.0 << QString("+-") << INV; |
|
257 |
QTest::newRow("2.9") << -10.0 << 10.0 << QString("-+") << INV; |
|
258 |
||
259 |
QTest::newRow("3.1") << 0.0 << 10.0 << QString("12345678901234567890") << INV; |
|
260 |
QTest::newRow("3.2") << 0.0 << 10.0 << QString("-12345678901234567890") << INV; |
|
261 |
QTest::newRow("3.3") << 0.0 << 10.0 << QString("000000000000000000000") << ACC; |
|
262 |
QTest::newRow("3.4") << 1.0 << 10.0 << QString("000000000000000000000") << ITM; |
|
263 |
QTest::newRow("3.5") << 0.0 << 10.0 << QString("-000000000000000000000") << INV; |
|
264 |
QTest::newRow("3.6") << -10.0 << -1.0 << QString("-000000000000000000000") << ITM; |
|
265 |
QTest::newRow("3.7") << -10.0 << -1.0 << QString("-0000000000000000000001") << ACC; |
|
266 |
||
267 |
QTest::newRow("4.1") << 0.0 << 10.0 << QString(" ") << INV; |
|
268 |
QTest::newRow("4.2") << 0.0 << 10.0 << QString(" 1") << INV; |
|
269 |
QTest::newRow("4.3") << 0.0 << 10.0 << QString("1 ") << INV; |
|
270 |
QTest::newRow("4.4") << 0.0 << 10.0 << QString("1.0") << INV; |
|
271 |
QTest::newRow("4.5") << 0.0 << 10.0 << QString("0.1") << INV; |
|
272 |
QTest::newRow("4.6") << 0.0 << 10.0 << QString(".1") << INV; |
|
273 |
QTest::newRow("4.7") << 0.0 << 10.0 << QString("-1.0") << INV; |
|
274 |
||
275 |
QTest::newRow("5.1") << 6.0 << 8.0 << QString("5") << ITM; |
|
276 |
QTest::newRow("5.1") << 6.0 << 8.0 << QString("56") << INV; |
|
277 |
QTest::newRow("5.2") << 6.0 << 8.0 << QString("7") << ACC; |
|
278 |
QTest::newRow("5.3") << 6.0 << 8.0 << QString("9") << ITM; |
|
279 |
QTest::newRow("5.3") << 6.0 << 8.0 << QString("-") << INV; |
|
280 |
QTest::newRow("5.4a") << -8.0 << -6.0 << QString("+") << INV; |
|
281 |
QTest::newRow("5.4b") << -8.0 << -6.0 << QString("+5") << INV; |
|
282 |
QTest::newRow("5.4c") << -8.0 << -6.0 << QString("-5") << ITM; |
|
283 |
QTest::newRow("5.5") << -8.0 << -6.0 << QString("-7") << ACC; |
|
284 |
QTest::newRow("5.6") << -8.0 << -6.0 << QString("-9") << ITM; |
|
285 |
QTest::newRow("5.7") << -8.0 << -6.0 << QString("5") << ITM; |
|
286 |
QTest::newRow("5.8") << -8.0 << -6.0 << QString("7") << ITM; |
|
287 |
QTest::newRow("5.9") << -8.0 << -6.0 << QString("9") << ITM; |
|
288 |
QTest::newRow("5.10") << -6.0 << 8.0 << QString("-5") << ACC; |
|
289 |
QTest::newRow("5.11") << -6.0 << 8.0 << QString("5") << ACC; |
|
290 |
QTest::newRow("5.12") << -6.0 << 8.0 << QString("-7") << ITM; |
|
291 |
QTest::newRow("5.13") << -6.0 << 8.0 << QString("7") << ACC; |
|
292 |
QTest::newRow("5.14") << -6.0 << 8.0 << QString("-9") << ITM; |
|
293 |
QTest::newRow("5.15") << -6.0 << 8.0 << QString("9") << ITM; |
|
294 |
||
295 |
QTest::newRow("6.1") << 100.0 << 102.0 << QString("11") << ITM; |
|
296 |
QTest::newRow("6.2") << 100.0 << 102.0 << QString("-11") << INV; |
|
297 |
||
298 |
QTest::newRow("7.1") << 0.0 << 10.0 << QString("100") << INV; |
|
299 |
QTest::newRow("7.2") << 0.0 << -10.0 << QString("100") << INV; |
|
300 |
QTest::newRow("7.3") << 0.0 << -10.0 << QString("-100") << INV; |
|
301 |
QTest::newRow("7.4") << -100.0 << 10.0 << QString("100") << ITM; |
|
302 |
} |
|
303 |
||
304 |
void tst_QDoubleValidator::validateIntEquiv() |
|
305 |
{ |
|
306 |
QFETCH(double, minimum); |
|
307 |
QFETCH(double, maximum); |
|
308 |
QFETCH(QString, input); |
|
309 |
QFETCH(QValidator::State, state); |
|
310 |
||
311 |
QDoubleValidator dv(minimum, maximum, 0, 0); |
|
312 |
dv.setNotation(QDoubleValidator::StandardNotation); |
|
313 |
int dummy; |
|
314 |
QCOMPARE(dv.validate(input, dummy), state); |
|
315 |
} |
|
316 |
||
317 |
QTEST_APPLESS_MAIN(tst_QDoubleValidator) |
|
318 |
#include "tst_qdoublevalidator.moc" |