Verified Commit ed78d2d3 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

converterrunner: Add test case for rounding of currencies

parent 6da4e3dd
......@@ -7,6 +7,7 @@
#include <KRunner/AbstractRunnerTest>
#include <KUnitConversion/Converter>
#include <KUnitConversion/UnitCategory>
#include <QRegularExpression>
#include <QTest>
using namespace KUnitConversion;
......@@ -24,6 +25,7 @@ private Q_SLOTS:
void testQuery();
void testInvalidQuery_data();
void testInvalidQuery();
void testRoundingOfCurrencies();
};
void ConverterRunnerTest::initTestCase()
......@@ -127,6 +129,17 @@ void ConverterRunnerTest::testInvalidQuery()
QCOMPARE(manager->matches().count(), 0);
}
void ConverterRunnerTest::testRoundingOfCurrencies()
{
launchQuery(QStringLiteral("40000000000000000000000000000000000000000000000000$"));
QVERIFY(!manager->matches().isEmpty());
QVERIFY(!manager->matches().constFirst().text().startsWith("-"));
launchQuery(QStringLiteral("50.123$"));
QVERIFY(!manager->matches().isEmpty());
QRegularExpression hasTwoDecimalPrescision(QStringLiteral(R"(^\d+\.\d\d)"));
QVERIFY(manager->matches().constFirst().text().contains(hasTwoDecimalPrescision));
}
QTEST_MAIN(ConverterRunnerTest)
#include "converterrunnertest.moc"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment