From 3c0ac5208111c85c405ba1ee6ce3189a6c4e1236 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 23 Nov 2012 11:45:01 +0200 Subject: QLocale: Fix toCurrencyString() didn't respect group separator option Change-Id: Icda43d71d600d77fe1ed4fcde1ef4478ef29c1d5 Reviewed-by: Lars Knoll Reviewed-by: Denis Dzyubenko --- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 36 ++++++++++++++---------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'tests') 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"))); -- cgit v1.2.3