From 78d47f520b2c4acdf782d39311063f5d44376913 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 14 Apr 2011 13:08:53 +0200 Subject: QLocale: Fixed double to currency string conversion on Mac. This also fixes the autotest failure on mac with macDefaultLocale test. Reviewed-by: trustme --- src/corelib/tools/qlocale_mac.mm | 2 +- tests/auto/qlocale/tst_qlocale.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm index 29d9a53..52005e0 100644 --- a/src/corelib/tools/qlocale_mac.mm +++ b/src/corelib/tools/qlocale_mac.mm @@ -318,7 +318,7 @@ static QString macFormatCurrency(const QSystemLocale::CurrencyToStringArgument & break; } case QVariant::Double: { - double v = arg.value.toInt(); + double v = arg.value.toDouble(); value = CFNumberCreate(NULL, kCFNumberDoubleType, &v); break; } diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp index cabf12e..2b7eaae 100644 --- a/tests/auto/qlocale/tst_qlocale.cpp +++ b/tests/auto/qlocale/tst_qlocale.cpp @@ -1130,10 +1130,10 @@ void tst_QLocale::macDefaultLocale() const QString timeString = locale.toString(QTime(1,2,3), QLocale::LongFormat); QVERIFY(timeString.contains(QString("1:02:03"))); - QCOMPARE(locale.toCurrencyString(qulonglong(1234)), QString("$1,234")); - QCOMPARE(locale.toCurrencyString(qlonglong(-1234)), QString("$-1,234")); + QCOMPARE(locale.toCurrencyString(qulonglong(1234)), QString("$1,234.00")); + QCOMPARE(locale.toCurrencyString(qlonglong(-1234)), QString("($1,234.00)")); QCOMPARE(locale.toCurrencyString(double(1234.56)), QString("$1,234.56")); - QCOMPARE(locale.toCurrencyString(double(-1234.56)), QString("$-1,234.56")); + QCOMPARE(locale.toCurrencyString(double(-1234.56)), QString("($1,234.56)")); // Depending on the configured time zone, the time string might not // contain a GMT specifier. (Sometimes it just names the zone, like "CEST") -- cgit v0.12