From 3cdf8debd1f8bd9d3ebe598e36b99548db8b6bc7 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 8 Feb 2017 19:02:01 +0100 Subject: 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 --- tests/auto/corelib/tools/qdate/tst_qdate.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/auto/corelib/tools/qdate/tst_qdate.cpp') 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("format"); QTest::addColumn("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); -- cgit v1.2.3