Commit 174eae5bedb96c7f102e5ea4ef3d84c49c17c5ec
1 parent
dce20eb2
Exists in
master
Adicionado método de converter double para QString sem notação científica.
Showing
3 changed files
with
19 additions
and
0 deletions
Show diff stats
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
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. | ... | ... |