diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-06-23 12:36:52 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-07-02 11:33:01 +0200 |
commit | ca8b2a36324d205d4a8482b522f32f5377b0b962 (patch) | |
tree | 6f1401608ce78d3c84065afc82a679094826d1b4 /tests | |
parent | 6dd9c0720b3ae814aecf50453e91c3b450085471 (diff) |
Remove assortee pre-Qt6 code from date/time tests
Assume QT_VERSION >= QT_VERSION_CHECK(6,0,0) throughout.
Change-Id: If70c59f9319f72549de581fc446fd60d32b02521
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/time/qdate/tst_qdate.cpp | 14 | ||||
-rw-r--r-- | tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp | 86 | ||||
-rw-r--r-- | tests/auto/corelib/time/qtime/tst_qtime.cpp | 47 |
3 files changed, 0 insertions, 147 deletions
diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 6c6014600d..743cac4d3c 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -1340,18 +1340,6 @@ void tst_QDate::toStringDateFormat() QFETCH(Qt::DateFormat, format); QFETCH(QString, expectedStr); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QCOMPARE(date.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(date, QLocale::ShortFormat)); - QCOMPARE(date.toString(Qt::DefaultLocaleShortDate), QLocale().toString(date, QLocale::ShortFormat)); - QCOMPARE(date.toString(Qt::SystemLocaleLongDate), QLocale::system().toString(date, QLocale::LongFormat)); - QCOMPARE(date.toString(Qt::DefaultLocaleLongDate), QLocale().toString(date, QLocale::LongFormat)); - QLocale::setDefault(QLocale::German); - QCOMPARE(date.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(date, QLocale::ShortFormat)); - QCOMPARE(date.toString(Qt::DefaultLocaleShortDate), QLocale().toString(date, QLocale::ShortFormat)); - QCOMPARE(date.toString(Qt::SystemLocaleLongDate), QLocale::system().toString(date, QLocale::LongFormat)); - QCOMPARE(date.toString(Qt::DefaultLocaleLongDate), QLocale().toString(date, QLocale::LongFormat)); -#endif // ### Qt 6: remove - QCOMPARE(date.toString(format), expectedStr); } @@ -1452,9 +1440,7 @@ void tst_QDate::printNegativeYear() const { QFETCH(int, year); QFETCH(QString, expect); -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) expect.replace(QLatin1Char('-'), QLocale().negativeSign()); -#endif QDate date(year, 3, 4); QVERIFY(date.isValid()); diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index 9d5a949277..32d3b08376 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -31,9 +31,6 @@ #include <time.h> #include <qdatetime.h> #include <private/qdatetime_p.h> -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -# include <locale.h> -#endif #ifdef Q_OS_WIN # include <qt_windows.h> @@ -50,7 +47,6 @@ public: static QDateTime dt( const QString& str ); public Q_SLOTS: void initTestCase(); - void init(); private Q_SLOTS: void ctor(); void operator_eq(); @@ -121,10 +117,6 @@ private Q_SLOTS: void fromStringStringFormat(); void fromStringStringFormat_localTimeZone_data(); void fromStringStringFormat_localTimeZone(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - void fromStringToStringLocale_data(); - void fromStringToStringLocale(); -#endif // ### Qt 6: remove void offsetFromUtc(); void setOffsetFromUtc(); @@ -193,14 +185,6 @@ Q_DECLARE_METATYPE(Qt::DateFormat) tst_QDateTime::tst_QDateTime() { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - // Some tests depend on C locale - BF&I it with belt *and* braces: - qputenv("LC_ALL", "C"); - setlocale(LC_ALL, "C"); - // Need to do this as early as possible, before anything accesses the - // QSystemLocale singleton; once it exists, there's no changing it. -#endif // remove for ### Qt 6 - /* Due to some jurisdictions changing their zones and rules, it's possible for a non-CET zone to accidentally match CET at a few tested moments but @@ -291,13 +275,6 @@ void tst_QDateTime::initTestCase() << "the Central European timezone"; } -void tst_QDateTime::init() -{ -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); -#endif // ### Qt 6: remove -} - QString tst_QDateTime::str( int y, int month, int d, int h, int min, int s ) { return QDateTime( QDate(y, month, d), QTime(h, min, s) ).toString( Qt::ISODate ); @@ -866,11 +843,6 @@ void tst_QDateTime::toString_isoDate() QFETCH(Qt::DateFormat, format); QFETCH(QString, expected); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QLocale oldLocale; - QLocale::setDefault(QLocale("en_US")); -#endif // ### Qt 6: remove - QString result = datetime.toString(format); QCOMPARE(result, expected); @@ -887,10 +859,6 @@ void tst_QDateTime::toString_isoDate() } else { QCOMPARE(resultDatetime, QDateTime()); } - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QLocale::setDefault(oldLocale); -#endif // ### Qt 6: remove } void tst_QDateTime::toString_isoDate_extra() @@ -2254,12 +2222,7 @@ void tst_QDateTime::fromStringDateFormat_data() // Spaces as separators: QTest::newRow("sec-milli space") << QString("2000-01-02 03:04:05 678") << Qt::ISODate -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) << invalidDateTime(); -#else - // Should be invalid, but we ignore trailing cruft (in some cases) - << QDateTime(QDate(2000, 1, 2), QTime(3, 4, 5)); -#endif QTest::newRow("min-sec space") << QString("2000-01-02 03:04 05.678") << Qt::ISODate << QDateTime(); QTest::newRow("hour-min space") @@ -2347,11 +2310,7 @@ void tst_QDateTime::fromStringDateFormat_data() << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0), Qt::LocalTime); // Test invalid characters (should ignore invalid characters at end of string). QTest::newRow("ISO invalid character at end") << QString::fromLatin1("2012-01-01T08:00:00!") -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) << Qt::ISODate << invalidDateTime(); -#else - << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0), Qt::LocalTime); -#endif QTest::newRow("ISO invalid character at front") << QString::fromLatin1("!2012-01-01T08:00:00") << Qt::ISODate << invalidDateTime(); QTest::newRow("ISO invalid character both ends") << QString::fromLatin1("!2012-01-01T08:00:00!") @@ -2730,51 +2689,6 @@ void tst_QDateTime::fromStringStringFormat_localTimeZone() fromStringStringFormat(); // call basic fromStringStringFormat test } -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED - -void tst_QDateTime::fromStringToStringLocale_data() -{ - QTest::addColumn<QLocale>("locale"); - QTest::addColumn<QDateTime>("dateTime"); - - QTest::newRow("frFR") << QLocale(QLocale::French, QLocale::France) << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00)); - QTest::newRow("spCO") << QLocale(QLocale::Spanish, QLocale::Colombia) << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00)); -} - -void tst_QDateTime::fromStringToStringLocale() -{ - QFETCH(QLocale, locale); - QFETCH(QDateTime, dateTime); - - QLocale def; - QLocale::setDefault(locale); -#define ROUNDTRIP(format) \ - QCOMPARE(QDateTime::fromString(dateTime.toString(format), format), dateTime) - - ROUNDTRIP(Qt::DefaultLocaleShortDate); - ROUNDTRIP(Qt::SystemLocaleShortDate); - - // obsolete - ROUNDTRIP(Qt::SystemLocaleDate); - ROUNDTRIP(Qt::LocaleDate); - -#if !QT_CONFIG(timezone) - QEXPECT_FAIL("", "Long date formats (with time-zone specifiers) need timezone feature enabled", - Continue); -#endif - ROUNDTRIP(Qt::DefaultLocaleLongDate); -#if !QT_CONFIG(timezone) - QEXPECT_FAIL("", "Long date formats (with time-zone specifiers) need timezone feature enabled", - Continue); -#endif - ROUNDTRIP(Qt::SystemLocaleLongDate); -#undef ROUNDTRIP - QLocale::setDefault(def); -} -QT_WARNING_POP -#endif // ### Qt 6: remove - void tst_QDateTime::offsetFromUtc() { /* Check default value. */ diff --git a/tests/auto/corelib/time/qtime/tst_qtime.cpp b/tests/auto/corelib/time/qtime/tst_qtime.cpp index 69da4b083f..764b2b8351 100644 --- a/tests/auto/corelib/time/qtime/tst_qtime.cpp +++ b/tests/auto/corelib/time/qtime/tst_qtime.cpp @@ -36,18 +36,6 @@ class tst_QTime : public QObject { Q_OBJECT -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -public: - tst_QTime() - { - // Some tests depend on C locale - BF&I it with belt *and* braces: - qputenv("LC_ALL", "C"); - setlocale(LC_ALL, "C"); - // Need to instantiate as early as possible, before anything accesses - // the QSystemLocale singleton; once it exists, there's no changing it. - } -#endif // remove for ### Qt 6 - private Q_SLOTS: void msecsTo_data(); void msecsTo(); @@ -77,9 +65,6 @@ private Q_SLOTS: void toStringDateFormat(); void toStringFormat_data(); void toStringFormat(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - void toStringLocale(); -#endif // ### Qt 6: remove void msecsSinceStartOfDay_data(); void msecsSinceStartOfDay(); @@ -593,11 +578,7 @@ void tst_QTime::fromStringDateFormat_data() QTest::newRow("TextDate - invalid, minute fraction") << QString::fromLatin1("23:00.123456") << Qt::TextDate << invalidTime(); QTest::newRow("TextDate - invalid, seconds") << QString::fromLatin1("23:00:XX") << Qt::TextDate << invalidTime(); QTest::newRow("TextDate - invalid, milliseconds") << QString::fromLatin1("23:01:01:XXXX") << Qt::TextDate -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) << invalidTime(); -#else - << QTime(23, 1, 1, 0); -#endif QTest::newRow("TextDate - midnight 24") << QString("24:00:00") << Qt::TextDate << QTime(); QTest::newRow("IsoDate - valid, start of day, omit seconds") << QString::fromLatin1("00:00") << Qt::ISODate << QTime(0, 0, 0); @@ -615,11 +596,7 @@ void tst_QTime::fromStringDateFormat_data() QTest::newRow("IsoDate - invalid, minute fraction") << QString::fromLatin1("23:00,XX") << Qt::ISODate << invalidTime(); QTest::newRow("IsoDate - invalid, seconds") << QString::fromLatin1("23:00:XX") << Qt::ISODate << invalidTime(); QTest::newRow("IsoDate - invalid, milliseconds") << QString::fromLatin1("23:01:01:XXXX") << Qt::ISODate -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) << invalidTime(); -#else - << QTime(23, 1, 1, 0); -#endif QTest::newRow("IsoDate - data0") << QString("00:00:00") << Qt::ISODate << QTime(0,0,0,0); QTest::newRow("IsoDate - data1") << QString("10:12:34") << Qt::ISODate << QTime(10,12,34,0); QTest::newRow("IsoDate - data2") << QString("19:03:54.998601") << Qt::ISODate << QTime(19, 3, 54, 999); @@ -774,30 +751,6 @@ void tst_QTime::toStringFormat() QCOMPARE( t.toString( format ), str ); } -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -void tst_QTime::toStringLocale() -{ - QTime time(18, 30); - QCOMPARE(time.toString(Qt::SystemLocaleShortDate), - QLocale::system().toString(time, QLocale::ShortFormat)); - QCOMPARE(time.toString(Qt::DefaultLocaleShortDate), - QLocale().toString(time, QLocale::ShortFormat)); - QCOMPARE(time.toString(Qt::SystemLocaleLongDate), - QLocale::system().toString(time, QLocale::LongFormat)); - QCOMPARE(time.toString(Qt::DefaultLocaleLongDate), - QLocale().toString(time, QLocale::LongFormat)); - QLocale::setDefault(QLocale::German); - QCOMPARE(time.toString(Qt::SystemLocaleShortDate), - QLocale::system().toString(time, QLocale::ShortFormat)); - QCOMPARE(time.toString(Qt::DefaultLocaleShortDate), - QLocale().toString(time, QLocale::ShortFormat)); - QCOMPARE(time.toString(Qt::SystemLocaleLongDate), - QLocale::system().toString(time, QLocale::LongFormat)); - QCOMPARE(time.toString(Qt::DefaultLocaleLongDate), - QLocale().toString(time, QLocale::LongFormat)); -} -#endif // ### Qt 6: remove - void tst_QTime::msecsSinceStartOfDay_data() { QTest::addColumn<int>("msecs"); |