Skip to content

Commit 63d063f

Browse files
committed
Update the tests with QgsField precision values
Now that they are honored
1 parent 33fe8fa commit 63d063f

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

tests/src/gui/testqgsrangewidgetwrapper.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ void TestQgsRangeWidgetWrapper::init()
7474
// add fields
7575
QList<QgsField> fields;
7676
fields.append( QgsField( "id", QVariant::Int ) );
77-
// 9 precision
77+
// precision = 9
7878
QgsField dfield( "number", QVariant::Double );
7979
dfield.setPrecision( 9 );
8080
fields.append( dfield );
81-
// default precision
81+
// default precision = 0
8282
QgsField dfield2( "number_def", QVariant::Double );
8383
fields.append( dfield2 );
8484
vl->dataProvider()->addAttributes( fields );
@@ -137,17 +137,15 @@ void TestQgsRangeWidgetWrapper::test_setDoubleRange()
137137
widget2->setFeature( vl->getFeature( 1 ) );
138138
QCOMPARE( vl->fields().at( 1 ).precision(), 9 );
139139
// 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
141140
QCOMPARE( vl->fields().at( 2 ).precision(), 0 );
142141
QCOMPARE( editor->decimals(), vl->fields().at( 1 ).precision() );
143142
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() );
146144
QCOMPARE( editor->valueFromText( feat.attribute( 1 ).toString() ), 123.123456789 );
147145
QCOMPARE( feat.attribute( 1 ).toString(), QStringLiteral( "123.123456789" ) );
148146
QCOMPARE( editor2->valueFromText( feat.attribute( 1 ).toString() ), 123.123456789 );
149147
QCOMPARE( editor->value( ), 123.123456789 );
150-
QCOMPARE( editor2->value( ), 123.12 );
148+
QCOMPARE( editor2->value( ), 123.0 );
151149
QCOMPARE( editor->minimum( ), std::numeric_limits<double>::lowest() );
152150
QCOMPARE( editor2->minimum( ), std::numeric_limits<double>::lowest() );
153151
QCOMPARE( editor->maximum( ), std::numeric_limits<double>::max() );
@@ -161,7 +159,7 @@ void TestQgsRangeWidgetWrapper::test_setDoubleRange()
161159
widget->setFeature( vl->getFeature( 3 ) );
162160
widget2->setFeature( vl->getFeature( 3 ) );
163161
QCOMPARE( editor->value( ), -123.123456789 );
164-
QCOMPARE( editor2->value( ), -123.12 );
162+
QCOMPARE( editor2->value( ), -123.0 );
165163
}
166164

167165
void TestQgsRangeWidgetWrapper::test_setDoubleSmallerRange()
@@ -189,11 +187,9 @@ void TestQgsRangeWidgetWrapper::test_setDoubleSmallerRange()
189187

190188
QCOMPARE( vl->fields().at( 1 ).precision(), 9 );
191189
// 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
193190
QCOMPARE( vl->fields().at( 2 ).precision(), 0 );
194191
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() );
197193
// value was changed to the maximum (not NULL) accepted value
198194
QCOMPARE( editor->value( ), 100.0 );
199195
// value was changed to the maximum (not NULL) accepted value
@@ -250,13 +246,11 @@ void TestQgsRangeWidgetWrapper::test_setDoubleLimits()
250246

251247
QCOMPARE( vl->fields().at( 1 ).precision(), 9 );
252248
// 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
254249
QCOMPARE( vl->fields().at( 2 ).precision(), 0 );
255250
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() );
258252
QCOMPARE( editor->value( ), 123.123456789 );
259-
QCOMPARE( editor2->value( ), 123.12 );
253+
QCOMPARE( editor2->value( ), 123.0 );
260254

261255
// NULL, NULL
262256
widget->setFeature( vl->getFeature( 2 ) );
@@ -269,7 +263,7 @@ void TestQgsRangeWidgetWrapper::test_setDoubleLimits()
269263
widget2->setFeature( vl->getFeature( 3 ) );
270264
// value was changed to the minimum
271265
QCOMPARE( editor->value( ), -123.123456789 );
272-
QCOMPARE( editor2->value( ), -123.12 );
266+
QCOMPARE( editor2->value( ), -123.0 );
273267

274268
}
275269

0 commit comments

Comments
 (0)