From a1c27748d22f94d608cc499db527bf989a5516f2 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 2 Mar 2017 14:23:05 +0100 Subject: Make QLocale consistent about special handling of the C locale QLocale::matchingLocales() simply created each locale using the basic data, without (unless the matching conditions stipulated Language C) applying number-options hacks that it applies everywhere else, when creating the C locale. Thus the C locale in its returned list (if it wasn't the only entry) ended up with the default number options, without omiting separators in numbers. Thus QLocale::c() didn't actually appear as an entry in the list. Discovered while investigating QTBUG-58947. Added a dumb autotest that checks various ways of getting the C locale do actually give us equal locale objects. Fixed matchingLocales() to apply the same hack as is used elsewhere for the C locale. Change-Id: I263f31da623052b63171f5b5a83c65802383df21 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 06b0fe8d51..d18af71e20 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -80,6 +80,7 @@ private slots: void ctor(); void emptyCtor(); void legacyNames(); + void consistentC(); void unixLocaleName(); void matchingLocales(); void stringToDouble_data(); @@ -579,6 +580,15 @@ void tst_QLocale::legacyNames() #undef TEST_CTOR } +void tst_QLocale::consistentC() +{ + const QLocale c(QLocale::C); + QCOMPARE(c, QLocale::c()); + QCOMPARE(c, QLocale(QLocale::C, QLocale::AnyScript, QLocale::AnyCountry)); + QVERIFY(QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, + QLocale::AnyCountry).contains(c)); +} + void tst_QLocale::matchingLocales() { const QLocale c(QLocale::C); -- cgit v1.2.3