Commit 174eae5bedb96c7f102e5ea4ef3d84c49c17c5ec

Authored by Thiago Rocha
1 parent dce20eb2
Exists in master

Adicionado método de converter double para QString sem notação científica.

cacic-teste/testcacic.cpp
... ... @@ -243,6 +243,15 @@ void CTestCacic::testColetaSoftware()
243 243 QVERIFY(!OCacicSoftware.toJsonObject().empty());
244 244 }
245 245  
  246 +void CTestCacic::testConvertDouble()
  247 +{
  248 + double number = 4.0905;
  249 +
  250 + QString converted = OCacic.convertDouble(number);
  251 +
  252 + QVERIFY(converted.toDouble() == number);
  253 +}
  254 +
246 255 void CTestCacic::cleanupTestCase()
247 256 {
248 257 OCacic.deleteFile("configRequest.json");
... ...
cacic-teste/testcacic.h
... ... @@ -70,6 +70,7 @@ private slots:
70 70 void testRemoveRegistry();
71 71 void testIniciarDaemon();
72 72 void testColetaSoftware();
  73 + void testConvertDouble();
73 74 void cleanupTestCase();
74 75 };
75 76  
... ...
src/ccacic.cpp
... ... @@ -286,6 +286,15 @@ void CCacic::setChaveCrypt(const QString &value)
286 286 chaveCrypt = value;
287 287 }
288 288  
  289 +QString CCacic::convertDouble(const double &number, const int &precision)
  290 +{
  291 + std::ostringstream ss;
  292 + ss.precision(precision);
  293 + ss << std::fixed << number;
  294 +
  295 + qDebug() << QString::fromStdString(ss.str());
  296 + return QString::fromStdString(ss.str());
  297 +}
289 298  
290 299 /*Getters/Setters
291 300 * End.
... ...