diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-08-03 11:06:24 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-08-04 22:22:20 +0200 |
commit | a13942791d4bc26c0be15f4fd752a5c3b4a4b806 (patch) | |
tree | c86b5a612e94c13831d2689ee433b650a022a585 /tests | |
parent | b41d5f62932b4c833d3162cc22bc07172559b1ec (diff) |
Refine localeAwareCompare() test-case filtering on ICU
The code to work around setlocale() mis-describing en_US as C ensured
that we didn't accept the C test-cases when the locale was really
en_US; but neglected to accept the en_US test-cases when the locale
really was en_US but was misdescribed as C. This lead to no tests
being run when the locale was en_US.
Tweak the logic of the test filtering to compare the wanted locale
against the system locale both when C is wanted and when it isn't.
Make the skip-messages a little more informative.
Pick-to: 6.2 6.1
Change-Id: I4e072e12819144b2941b87a5f486534047d9a579
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/text/qstring/tst_qstring.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 563d24b606..641bc7d775 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -5949,12 +5949,14 @@ void tst_QString::localeAwareCompare_data() // to en.UTF-8, but setlocale() reports that as C, whose sort order is // simpler. Only believe we can run C tests if the environment variables // (which, conveniently, QLocale::system()'s Unix backend uses) say it - // really is. - if (current == "C" && current == wanted) { - if (QLocale::system().name() == u"C") + // really is. Conversely, don't reject "en_US" just because setlocale() + // misdescribes it. + if (current == "C") { + const QString sys = QLocale::system().name(); + if (wanted == current ? sys == u"C" : sys.startsWith(wanted)) return true; - qDebug("Skipping C test-cases as we can only test in locale %s", - QLocale::system().name().toUtf8().constData()); + qDebug("Skipping %s test-cases as we can only test in locale %s (seen as C)", + wanted, sys.toUtf8().constData()); return false; } # endif @@ -5970,7 +5972,8 @@ void tst_QString::localeAwareCompare_data() return true; } # endif - qDebug("Skipping %s test-cases as we can only test in locale %s", wanted, current.data()); + qDebug("Skipping %s test-cases as we can only test in locale %s (seen as %s)", + wanted, QLocale::system().name().toUtf8().constData(), current.data()); return false; }; #else |