@@ -74,11 +74,11 @@ void TestQgsRangeWidgetWrapper::init()
74
74
// add fields
75
75
QList<QgsField> fields;
76
76
fields.append ( QgsField ( " id" , QVariant::Int ) );
77
- // 9 precision
77
+ // precision = 9
78
78
QgsField dfield ( " number" , QVariant::Double );
79
79
dfield.setPrecision ( 9 );
80
80
fields.append ( dfield );
81
- // default precision
81
+ // default precision = 0
82
82
QgsField dfield2 ( " number_def" , QVariant::Double );
83
83
fields.append ( dfield2 );
84
84
vl->dataProvider ()->addAttributes ( fields );
@@ -137,17 +137,15 @@ void TestQgsRangeWidgetWrapper::test_setDoubleRange()
137
137
widget2->setFeature ( vl->getFeature ( 1 ) );
138
138
QCOMPARE ( vl->fields ().at ( 1 ).precision (), 9 );
139
139
// Default is 0 !!! for double, really ?
140
- // btw if it is 0 the decimals property in the spinbox is left to the default value of 2
141
140
QCOMPARE ( vl->fields ().at ( 2 ).precision (), 0 );
142
141
QCOMPARE ( editor->decimals (), vl->fields ().at ( 1 ).precision () );
143
142
QCOMPARE ( editor->decimals (), 9 );
144
- // This fails: QCOMPARE( editor2->decimals(), vl->fields().at( 2 ).precision() );
145
- QCOMPARE ( editor2->decimals (), 2 ); // Default spinbox decimals is 2
143
+ QCOMPARE ( editor2->decimals (), vl->fields ().at ( 2 ).precision () );
146
144
QCOMPARE ( editor->valueFromText ( feat.attribute ( 1 ).toString () ), 123.123456789 );
147
145
QCOMPARE ( feat.attribute ( 1 ).toString (), QStringLiteral ( " 123.123456789" ) );
148
146
QCOMPARE ( editor2->valueFromText ( feat.attribute ( 1 ).toString () ), 123.123456789 );
149
147
QCOMPARE ( editor->value ( ), 123.123456789 );
150
- QCOMPARE ( editor2->value ( ), 123.12 );
148
+ QCOMPARE ( editor2->value ( ), 123.0 );
151
149
QCOMPARE ( editor->minimum ( ), std::numeric_limits<double >::lowest () );
152
150
QCOMPARE ( editor2->minimum ( ), std::numeric_limits<double >::lowest () );
153
151
QCOMPARE ( editor->maximum ( ), std::numeric_limits<double >::max () );
@@ -161,7 +159,7 @@ void TestQgsRangeWidgetWrapper::test_setDoubleRange()
161
159
widget->setFeature ( vl->getFeature ( 3 ) );
162
160
widget2->setFeature ( vl->getFeature ( 3 ) );
163
161
QCOMPARE ( editor->value ( ), -123.123456789 );
164
- QCOMPARE ( editor2->value ( ), -123.12 );
162
+ QCOMPARE ( editor2->value ( ), -123.0 );
165
163
}
166
164
167
165
void TestQgsRangeWidgetWrapper::test_setDoubleSmallerRange ()
@@ -189,11 +187,9 @@ void TestQgsRangeWidgetWrapper::test_setDoubleSmallerRange()
189
187
190
188
QCOMPARE ( vl->fields ().at ( 1 ).precision (), 9 );
191
189
// Default is 0 !!! for double, really ?
192
- // btw if it is 0 the decimals property in the spinbox is left to the default value of 2
193
190
QCOMPARE ( vl->fields ().at ( 2 ).precision (), 0 );
194
191
QCOMPARE ( editor->decimals (), vl->fields ().at ( 1 ).precision () );
195
- // This fails: QCOMPARE( editor2->decimals(), vl->fields().at( 2 ).precision() );
196
- QCOMPARE ( editor2->decimals (), 2 ); // Default spinbox decimals is 2
192
+ QCOMPARE ( editor2->decimals (), vl->fields ().at ( 2 ).precision () );
197
193
// value was changed to the maximum (not NULL) accepted value
198
194
QCOMPARE ( editor->value ( ), 100.0 );
199
195
// value was changed to the maximum (not NULL) accepted value
@@ -250,13 +246,11 @@ void TestQgsRangeWidgetWrapper::test_setDoubleLimits()
250
246
251
247
QCOMPARE ( vl->fields ().at ( 1 ).precision (), 9 );
252
248
// Default is 0 !!! for double, really ?
253
- // btw if it is 0 the decimals property in the spinbox is left to the default value of 2
254
249
QCOMPARE ( vl->fields ().at ( 2 ).precision (), 0 );
255
250
QCOMPARE ( editor->decimals (), vl->fields ().at ( 1 ).precision () );
256
- // This fails: QCOMPARE( editor2->decimals(), vl->fields().at( 2 ).precision() );
257
- QCOMPARE ( editor2->decimals (), 2 ); // Default spinbox decimals is 2
251
+ QCOMPARE ( editor2->decimals (), vl->fields ().at ( 2 ).precision () );
258
252
QCOMPARE ( editor->value ( ), 123.123456789 );
259
- QCOMPARE ( editor2->value ( ), 123.12 );
253
+ QCOMPARE ( editor2->value ( ), 123.0 );
260
254
261
255
// NULL, NULL
262
256
widget->setFeature ( vl->getFeature ( 2 ) );
@@ -269,7 +263,7 @@ void TestQgsRangeWidgetWrapper::test_setDoubleLimits()
269
263
widget2->setFeature ( vl->getFeature ( 3 ) );
270
264
// value was changed to the minimum
271
265
QCOMPARE ( editor->value ( ), -123.123456789 );
272
- QCOMPARE ( editor2->value ( ), -123.12 );
266
+ QCOMPARE ( editor2->value ( ), -123.0 );
273
267
274
268
}
275
269
0 commit comments