diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index d5e2935d28..c6c16a5982 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -79,9 +79,7 @@ private slots: void ctor(); void emptyCtor(); - void legacyNames(); void consistentC(); - void unixLocaleName(); void matchingLocales(); void stringToDouble_data(); void stringToDouble(); @@ -108,8 +106,6 @@ private slots: void toDateTime(); void negativeNumbers(); void numberOptions(); - void testNames_data(); - void testNames(); void dayName_data(); void dayName(); void standaloneDayName_data(); @@ -143,6 +139,15 @@ private slots: void systemLocale(); + // *** ORDER-DEPENDENCY *** (This Is Bad.) + // Test order is determined by order of declaration here: *all* tests that + // QLocale::setDefault() *must* appear *after* all other tests ! + void defaulted_ctor(); // This one must be the first of these. + void legacyNames(); + void unixLocaleName(); + void testNames_data(); + void testNames(); + // DO NOT add tests here unless they QLocale::setDefault(); see above. private: QString m_decimal, m_thousand, m_sdate, m_ldate, m_time; QString m_sysapp; @@ -232,6 +237,23 @@ void tst_QLocale::ctor() TEST_CTOR(Chinese, LatinScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); #undef TEST_CTOR +} + +void tst_QLocale::defaulted_ctor() +{ + QLocale default_locale = QLocale::system(); + QLocale::Language default_lang = default_locale.language(); + QLocale::Country default_country = default_locale.country(); + + qDebug("Default: %s/%s", QLocale::languageToString(default_lang).toLatin1().constData(), + QLocale::countryToString(default_country).toLatin1().constData()); + + { + QLocale l(QLocale::C, QLocale::AnyCountry); + QCOMPARE(l.language(), QLocale::C); + QCOMPARE(l.country(), QLocale::AnyCountry); + } + #define TEST_CTOR(req_lang, req_country, exp_lang, exp_country) \ { \ QLocale l(QLocale::req_lang, QLocale::req_country); \ @@ -239,11 +261,6 @@ void tst_QLocale::ctor() QCOMPARE((int)l.country(), (int)exp_country); \ } - { - QLocale l(QLocale::C, QLocale::AnyCountry); - QCOMPARE(l.language(), QLocale::C); - QCOMPARE(l.country(), QLocale::AnyCountry); - } TEST_CTOR(AnyLanguage, AnyCountry, default_lang, default_country) TEST_CTOR(C, AnyCountry, QLocale::C, QLocale::AnyCountry) TEST_CTOR(Aymara, AnyCountry, default_lang, default_country) @@ -1961,10 +1978,11 @@ void tst_QLocale::testNames_data() QTest::addColumn("language"); QTest::addColumn("country"); + QLocale::setDefault(QLocale(QLocale::C)); // Ensures predictable fall-backs + for (int i = 0; i < locale_data_count; ++i) { const QLocaleData &item = locale_data[i]; - const QString testName = QLatin1String("data_") + QString::number(i) + QLatin1String(" (") + QLocale::languageToString((QLocale::Language)item.m_language_id) + QLatin1Char('/') + QLocale::countryToString((QLocale::Country)item.m_country_id)