summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qlocale.cpp7
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp36
2 files changed, 24 insertions, 19 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 2f0e4970b0..c49b3e0fff 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -3253,7 +3253,7 @@ QString QLocale::toCurrencyString(qlonglong value, const QString &symbol) const
size = d->m_data->m_currency_negative_format_size;
value = -value;
}
- QString str = d->longLongToString(value);
+ QString str = toString(value);
QString sym = symbol.isNull() ? currencySymbol() : symbol;
if (sym.isEmpty())
sym = currencySymbol(QLocale::CurrencyIsoCode);
@@ -3278,7 +3278,7 @@ QString QLocale::toCurrencyString(qulonglong value, const QString &symbol) const
const QLocaleData *data = this->d->m_data;
quint8 idx = data->m_currency_format_idx;
quint8 size = data->m_currency_format_size;
- QString str = d->unsLongLongToString(value);
+ QString str = toString(value);
QString sym = symbol.isNull() ? currencySymbol() : symbol;
if (sym.isEmpty())
sym = currencySymbol(QLocale::CurrencyIsoCode);
@@ -3308,8 +3308,7 @@ QString QLocale::toCurrencyString(double value, const QString &symbol) const
size = data->m_currency_negative_format_size;
value = -value;
}
- QString str = d->doubleToString(value, d->m_data->m_currency_digits,
- QLocalePrivate::DFDecimal);
+ QString str = toString(value, 'f', d->m_data->m_currency_digits);
QString sym = symbol.isNull() ? currencySymbol() : symbol;
if (sym.isEmpty())
sym = currencySymbol(QLocale::CurrencyIsoCode);
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 1756fec35b..911187da53 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -1678,25 +1678,31 @@ void tst_QLocale::standaloneMonthName()
void tst_QLocale::currency()
{
const QLocale c(QLocale::C);
- QCOMPARE(c.toCurrencyString(qulonglong(1234)), QString("1234"));
- QCOMPARE(c.toCurrencyString(qlonglong(-1234)), QString("-1234"));
- QCOMPARE(c.toCurrencyString(double(1234.56)), QString("1234.56"));
- QCOMPARE(c.toCurrencyString(double(-1234.56)), QString("-1234.56"));
+ QCOMPARE(c.toCurrencyString(qulonglong(1234)), QString("1,234"));
+ QCOMPARE(c.toCurrencyString(qlonglong(-1234)), QString("-1,234"));
+ QCOMPARE(c.toCurrencyString(double(1234.56)), QString("1,234.56"));
+ QCOMPARE(c.toCurrencyString(double(-1234.56)), QString("-1,234.56"));
+
+ const QLocale en_US("en_US");
+ QCOMPARE(en_US.toCurrencyString(qulonglong(1234)), QString("$1,234"));
+ QCOMPARE(en_US.toCurrencyString(qlonglong(-1234)), QString("($1,234)"));
+ QCOMPARE(en_US.toCurrencyString(double(1234.56)), QString("$1,234.56"));
+ QCOMPARE(en_US.toCurrencyString(double(-1234.56)), QString("($1,234.56)"));
const QLocale ru_RU("ru_RU");
- QCOMPARE(ru_RU.toCurrencyString(qulonglong(1234)), QString::fromUtf8("1234\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
- QCOMPARE(ru_RU.toCurrencyString(qlonglong(-1234)), QString::fromUtf8("-1234\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
- QCOMPARE(ru_RU.toCurrencyString(double(1234.56)), QString::fromUtf8("1234,56\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
- QCOMPARE(ru_RU.toCurrencyString(double(-1234.56)), QString::fromUtf8("-1234,56\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
+ QCOMPARE(ru_RU.toCurrencyString(qulonglong(1234)), QString::fromUtf8("1" "\xc2\xa0" "234\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
+ QCOMPARE(ru_RU.toCurrencyString(qlonglong(-1234)), QString::fromUtf8("-1" "\xc2\xa0" "234\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
+ QCOMPARE(ru_RU.toCurrencyString(double(1234.56)), QString::fromUtf8("1" "\xc2\xa0" "234,56\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
+ QCOMPARE(ru_RU.toCurrencyString(double(-1234.56)), QString::fromUtf8("-1" "\xc2\xa0" "234,56\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
const QLocale de_DE("de_DE");
- QCOMPARE(de_DE.toCurrencyString(qulonglong(1234)), QString::fromUtf8("1234\xc2\xa0\xe2\x82\xac"));
- QCOMPARE(de_DE.toCurrencyString(qulonglong(1234), QLatin1String("BAZ")), QString::fromUtf8("1234\xc2\xa0" "BAZ"));
- QCOMPARE(de_DE.toCurrencyString(qlonglong(-1234)), QString::fromUtf8("-1234\xc2\xa0\xe2\x82\xac"));
- QCOMPARE(de_DE.toCurrencyString(qlonglong(-1234), QLatin1String("BAZ")), QString::fromUtf8("-1234\xc2\xa0" "BAZ"));
- QCOMPARE(de_DE.toCurrencyString(double(1234.56)), QString::fromUtf8("1234,56\xc2\xa0\xe2\x82\xac"));
- QCOMPARE(de_DE.toCurrencyString(double(-1234.56)), QString::fromUtf8("-1234,56\xc2\xa0\xe2\x82\xac"));
- QCOMPARE(de_DE.toCurrencyString(double(-1234.56), QLatin1String("BAZ")), QString::fromUtf8("-1234,56\xc2\xa0" "BAZ"));
+ QCOMPARE(de_DE.toCurrencyString(qulonglong(1234)), QString::fromUtf8("1.234\xc2\xa0\xe2\x82\xac"));
+ QCOMPARE(de_DE.toCurrencyString(qulonglong(1234), QLatin1String("BAZ")), QString::fromUtf8("1.234\xc2\xa0" "BAZ"));
+ QCOMPARE(de_DE.toCurrencyString(qlonglong(-1234)), QString::fromUtf8("-1.234\xc2\xa0\xe2\x82\xac"));
+ QCOMPARE(de_DE.toCurrencyString(qlonglong(-1234), QLatin1String("BAZ")), QString::fromUtf8("-1.234\xc2\xa0" "BAZ"));
+ QCOMPARE(de_DE.toCurrencyString(double(1234.56)), QString::fromUtf8("1.234,56\xc2\xa0\xe2\x82\xac"));
+ QCOMPARE(de_DE.toCurrencyString(double(-1234.56)), QString::fromUtf8("-1.234,56\xc2\xa0\xe2\x82\xac"));
+ QCOMPARE(de_DE.toCurrencyString(double(-1234.56), QLatin1String("BAZ")), QString::fromUtf8("-1.234,56\xc2\xa0" "BAZ"));
const QLocale system = QLocale::system();
QVERIFY(system.toCurrencyString(1, QLatin1String("FOO")).contains(QLatin1String("FOO")));