File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -338,7 +338,10 @@ inline void ( *cast_to_fptr( void *p ) )()
338338//
339339inline QString qgsDoubleToString ( const double &a, const int &precision = 17 )
340340{
341- return QString::number ( a, ' f' , precision ).remove ( QRegExp ( " \\ .?0+$" ) );
341+ if ( precision )
342+ return QString::number ( a, ' f' , precision ).remove ( QRegExp ( " \\ .?0+$" ) );
343+ else
344+ return QString::number ( a, ' f' , precision );
342345}
343346
344347//
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ class TestQGis : public QObject
3535
3636 void permissiveToDouble ();
3737 void permissiveToInt ();
38+ void doubleToString ();
3839
3940 private:
4041 QString mReport ;
@@ -119,5 +120,14 @@ void TestQGis::permissiveToInt()
119120 QCOMPARE ( result, 1000 );
120121}
121122
123+ void TestQGis::doubleToString ()
124+ {
125+ QString result = qgsDoubleToString ( 5.6783212 , 5 );
126+ QVERIFY ( result == " 5.67832" );
127+ result = qgsDoubleToString ( 5.3456789 , 5 );
128+ QVERIFY ( result == " 5.34568" );
129+ result = qgsDoubleToString ( 12000 , 0 );
130+ QVERIFY ( result == " 12000" );
131+ }
122132QTEST_MAIN ( TestQGis )
123133#include " testqgis.moc"
You can’t perform that action at this time.
0 commit comments