QLocale: Fix toCurrencyString() didn't respect group separator option
Change-Id: Icda43d71d600d77fe1ed4fcde1ef4478ef29c1d5 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Denis Dzyubenko <denis@ddenis.info>bb10
parent
86bbe5a43a
commit
3c0ac52081
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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")));
|
||||
|
|
|
|||
Loading…
Reference in New Issue