summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qdate/tst_qdate.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2017-02-08 19:02:01 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2017-02-20 08:48:46 +0000
commit3cdf8debd1f8bd9d3ebe598e36b99548db8b6bc7 (patch)
tree0d6f5370cc4a800e90c0a87a4641d9c676cfa741 /tests/auto/corelib/tools/qdate/tst_qdate.cpp
parent567abeaa04db2c30f0d9a5cb95e11d295ad88784 (diff)
Make sure to use C locale during time tests that assume it
Some format and parse tests for time and date-time depended on locale but had test data for the C locale (so fail if the test-environment has, e.g., LANG=de_DE@utf8). So impose the C locale (until Qt 6). The date-time test did *some* attempts at fixing for locale, but failed to handle am/pm; and we do have "### Qt 6" comments in Q(Date|Time)+::fromString indicating that we intend to switch these methods to use the C locale by default (which shall fix this once and for all). So rip out the incomplete localization now and test we work properly at least when the locale used *is* C. Add a comment to the matching QDate test to rip out its (presently adequate) matching code once we do get to Qt 6 and make fromString() use the C locale. QDateTimeParser uses systemLocale(), which is initialized the first time it gets accessed; so we need to frob the locale *early*; doing so in the test-class constructor is about as early as we conveniently can; and seems to work (while doing it in individual tests does not). (There is no point rolling back at the end; the QSystemLocale global has been set up by then, so the roll-back would merely leave the global out of sync with setlocale() and the environment.) Task-number: QTBUG-58728 Change-Id: Ifa6778a80276050a099387a6dab15a1096be7561 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/corelib/tools/qdate/tst_qdate.cpp')
-rw-r--r--tests/auto/corelib/tools/qdate/tst_qdate.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp
index 0e189ba7aa..f88eac1a9f 100644
--- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp
+++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp
@@ -1033,7 +1033,8 @@ void tst_QDate::fromStringFormat_data()
QTest::addColumn<QString>("format");
QTest::addColumn<QDate>("expected");
- //get localized names
+ // Undo this (inline the C-locale versions) for ### Qt 6
+ // Get localized names:
QString january = QDate::longMonthName(1);
QString february = QDate::longMonthName(2);
QString march = QDate::longMonthName(3);