diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2015-01-21 11:14:34 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2015-01-21 11:14:34 +0100 |
commit | 112342b32650f56e289c7dcd181d5897b0b77a78 (patch) | |
tree | 76e9a37bcaa70097d009628bb2b116ea782c72cb /tests/auto/corelib | |
parent | 3bbc1bf53bac7648637d92abecadc568acfffb2d (diff) | |
parent | b6191b16d41459ed73cea738dfaf8e25e81ae22b (diff) |
Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto/corelib')
21 files changed, 218 insertions, 14 deletions
diff --git a/tests/auto/corelib/io/qdatastream/qdatastream.pro b/tests/auto/corelib/io/qdatastream/qdatastream.pro index 25c29b83ee..9ab2b0948d 100644 --- a/tests/auto/corelib/io/qdatastream/qdatastream.pro +++ b/tests/auto/corelib/io/qdatastream/qdatastream.pro @@ -5,3 +5,8 @@ SOURCES = tst_qdatastream.cpp TESTDATA += datastream.q42 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android: !android-no-sdk { + RESOURCES += \ + testdata.qrc +} diff --git a/tests/auto/corelib/io/qdatastream/testdata.qrc b/tests/auto/corelib/io/qdatastream/testdata.qrc new file mode 100644 index 0000000000..fb63cb3438 --- /dev/null +++ b/tests/auto/corelib/io/qdatastream/testdata.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>datastream.q42</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp b/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp index e4b5d9ab8f..5d1a743dd9 100644 --- a/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp +++ b/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp @@ -50,10 +50,10 @@ int main(int argc, char *argv[]) option = QString::fromLocal8Bit(argv[2]); if (option == "-crash") { - QLockFile *lockFile = new QLockFile(lockName); - lockFile->lock(); - // leak the lockFile on purpose, so that the lock remains! - return 0; + QLockFile lockFile(lockName); + lockFile.lock(); + // exit on purpose, so that the lock remains! + exit(0); } else if (option == "-busy") { QLockFile lockFile(lockName); lockFile.lock(); diff --git a/tests/auto/corelib/io/qtemporaryfile/android_testdata.qrc b/tests/auto/corelib/io/qtemporaryfile/android_testdata.qrc new file mode 100644 index 0000000000..f30290c262 --- /dev/null +++ b/tests/auto/corelib/io/qtemporaryfile/android_testdata.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/android_testdata"> + <file>tst_qtemporaryfile.cpp</file> + <file>resources/test.txt</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro b/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro index 8a91340e5f..c16a729ad0 100644 --- a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro +++ b/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro @@ -5,4 +5,8 @@ QT = core testlib SOURCES = tst_qtemporaryfile.cpp TESTDATA += tst_qtemporaryfile.cpp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -RESOURCES += qtemporaryfile.qrc
\ No newline at end of file +RESOURCES += qtemporaryfile.qrc + +android:!android-no-sdk { + RESOURCES += android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index a08a0ae777..29a3c4e18a 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -92,6 +92,24 @@ void tst_QTemporaryFile::initTestCase() // For QTBUG_4796 QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX")); QCoreApplication::setApplicationName("tst_qtemporaryfile"); + +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString sourceDir(":/android_testdata/"); + QDirIterator it(sourceDir, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo sourceFileInfo = it.fileInfo(); + if (!sourceFileInfo.isDir()) { + QFileInfo destinationFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1Char('/') + sourceFileInfo.filePath().mid(sourceDir.length())); + + if (!destinationFileInfo.exists()) { + QVERIFY(QDir().mkpath(destinationFileInfo.path())); + QVERIFY(QFile::copy(sourceFileInfo.filePath(), destinationFileInfo.filePath())); + } + } + } +#endif } void tst_QTemporaryFile::cleanupTestCase() @@ -253,20 +271,21 @@ void tst_QTemporaryFile::autoRemove() QVERIFY(!QFile::exists(fileName)); } +struct ChdirOnReturn +{ + ChdirOnReturn(const QString& d) : dir(d) {} + ~ChdirOnReturn() { + QDir::setCurrent(dir); + } + QString dir; +}; + void tst_QTemporaryFile::nonWritableCurrentDir() { #ifdef Q_OS_UNIX if (::geteuid() == 0) QSKIP("not valid running this test as root"); - struct ChdirOnReturn - { - ChdirOnReturn(const QString& d) : dir(d) {} - ~ChdirOnReturn() { - QDir::setCurrent(dir); - } - QString dir; - }; ChdirOnReturn cor(QDir::currentPath()); #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) @@ -443,6 +462,12 @@ void tst_QTemporaryFile::rename() void tst_QTemporaryFile::renameFdLeak() { #ifdef Q_OS_UNIX + +# if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + ChdirOnReturn cor(QDir::currentPath()); + QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); +# endif + const QByteArray sourceFile = QFile::encodeName(QFINDTESTDATA(__FILE__)); QVERIFY(!sourceFile.isEmpty()); // Test this on Unix only @@ -646,7 +671,11 @@ void tst_QTemporaryFile::createNativeFile_data() QTest::addColumn<bool>("valid"); QTest::addColumn<QByteArray>("content"); +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + const QString nativeFilePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/resources/test.txt"); +#else const QString nativeFilePath = QFINDTESTDATA("resources/test.txt"); +#endif QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray(); QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray(); diff --git a/tests/auto/corelib/kernel/qtranslator/android_testdata.qrc b/tests/auto/corelib/kernel/qtranslator/android_testdata.qrc new file mode 100644 index 0000000000..b33995ef21 --- /dev/null +++ b/tests/auto/corelib/kernel/qtranslator/android_testdata.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/android_testdata"> + <file>hellotr_la.qm</file> + <file>msgfmt_from_po.qm</file> + <file>dependencies_la.qm</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/kernel/qtranslator/qtranslator.pro b/tests/auto/corelib/kernel/qtranslator/qtranslator.pro index 41c3dea924..e588f44370 100644 --- a/tests/auto/corelib/kernel/qtranslator/qtranslator.pro +++ b/tests/auto/corelib/kernel/qtranslator/qtranslator.pro @@ -4,4 +4,6 @@ QT = core testlib SOURCES = tst_qtranslator.cpp RESOURCES += qtranslator.qrc -TESTDATA += hellotr_la.qm msgfmt_from_po.qm +android:!android-no-sdk: RESOURCES += android_testdata.qrc +else: TESTDATA += hellotr_la.qm msgfmt_from_po.qm + diff --git a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp index 802d649496..077da6fce8 100644 --- a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp +++ b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp @@ -68,6 +68,26 @@ tst_QTranslator::tst_QTranslator() void tst_QTranslator::initTestCase() { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString sourceDir(":/android_testdata/"); + QDirIterator it(sourceDir, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo sourceFileInfo = it.fileInfo(); + if (!sourceFileInfo.isDir()) { + QFileInfo destinationFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1Char('/') + sourceFileInfo.filePath().mid(sourceDir.length())); + + if (!destinationFileInfo.exists()) { + QVERIFY(QDir().mkpath(destinationFileInfo.path())); + QVERIFY(QFile::copy(sourceFileInfo.filePath(), destinationFileInfo.filePath())); + } + } + } + + QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); +#endif + // chdir into the directory containing our testdata, // to make the code simpler (load testdata via relative paths) QString testdata_dir = QFileInfo(QFINDTESTDATA("hellotr_la.qm")).absolutePath(); diff --git a/tests/auto/corelib/tools/qbytearray/android_testdata.qrc b/tests/auto/corelib/tools/qbytearray/android_testdata.qrc new file mode 100644 index 0000000000..5d42f0f627 --- /dev/null +++ b/tests/auto/corelib/tools/qbytearray/android_testdata.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>rfc3252.txt</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/tools/qbytearray/qbytearray.pro b/tests/auto/corelib/tools/qbytearray/qbytearray.pro index 8d2efce0be..22104f817f 100644 --- a/tests/auto/corelib/tools/qbytearray/qbytearray.pro +++ b/tests/auto/corelib/tools/qbytearray/qbytearray.pro @@ -10,3 +10,8 @@ mac { OBJECTIVE_SOURCES += tst_qbytearray_mac.mm LIBS += -framework Foundation } + +android: !android-no-sdk { + RESOURCES += \ + android_testdata.qrc +} diff --git a/tests/auto/corelib/tools/qchar/qchar.pro b/tests/auto/corelib/tools/qchar/qchar.pro index 0738abad3a..a72f16fa49 100644 --- a/tests/auto/corelib/tools/qchar/qchar.pro +++ b/tests/auto/corelib/tools/qchar/qchar.pro @@ -5,3 +5,8 @@ SOURCES = tst_qchar.cpp TESTDATA += data/NormalizationTest.txt DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android: !android-no-sdk { + RESOURCES += \ + testdata.qrc +} diff --git a/tests/auto/corelib/tools/qchar/testdata.qrc b/tests/auto/corelib/tools/qchar/testdata.qrc new file mode 100644 index 0000000000..7b3fb2461c --- /dev/null +++ b/tests/auto/corelib/tools/qchar/testdata.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>data/NormalizationTest.txt</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp index f55e2eac42..96c7064d23 100644 --- a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp +++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp @@ -170,6 +170,11 @@ void tst_QCollator::compare() QCollator collator(locale); +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + if (collator.locale() != QLocale()) + QSKIP("Posix implementation of collation only supports default locale"); +#endif + if (numericMode) collator.setNumericMode(true); diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index 7062d4cad9..ff9b63703c 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -472,6 +472,10 @@ void tst_QCommandLineParser::testVersionOption() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QSKIP("Deploying executable applications to file system on Android not supported."); +#endif + QCoreApplication app(empty_argc, empty_argv); QProcess process; process.start("testhelper/qcommandlineparser_test_helper", QStringList() << "0" << "--version"); @@ -537,6 +541,9 @@ void tst_QCommandLineParser::testHelpOption() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QSKIP("Deploying executable applications to file system on Android not supported."); +#endif QFETCH(QCommandLineParser::SingleDashWordOptionMode, parsingMode); QFETCH(QString, expectedHelpOutput); @@ -581,6 +588,8 @@ void tst_QCommandLineParser::testQuoteEscaping() { #ifdef QT_NO_PROCESS QSKIP("This test requires QProcess support"); +#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QSKIP("Deploying executable applications to file system on Android not supported."); #else QCoreApplication app(empty_argc, empty_argv); QProcess process; diff --git a/tests/auto/corelib/tools/qcryptographichash/qcryptographichash.pro b/tests/auto/corelib/tools/qcryptographichash/qcryptographichash.pro index f7725ab188..941a068f8e 100644 --- a/tests/auto/corelib/tools/qcryptographichash/qcryptographichash.pro +++ b/tests/auto/corelib/tools/qcryptographichash/qcryptographichash.pro @@ -5,3 +5,8 @@ SOURCES = tst_qcryptographichash.cpp TESTDATA += data/* DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android: !android-no-sdk { + RESOURCES += \ + testdata.qrc +} diff --git a/tests/auto/corelib/tools/qcryptographichash/testdata.qrc b/tests/auto/corelib/tools/qcryptographichash/testdata.qrc new file mode 100644 index 0000000000..8f7bcea63c --- /dev/null +++ b/tests/auto/corelib/tools/qcryptographichash/testdata.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>data/2c1517dad3678f03917f15849b052fd5.md5</file> + <file>data/d41d8cd98f00b204e9800998ecf8427e.md5</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 8876bb3d34..e992c41bc1 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -1903,6 +1903,14 @@ void tst_QDateTime::fromStringDateFormat_data() << Qt::ISODate << QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::UTC); QTest::newRow("ISO +00:00") << QString::fromLatin1("1970-01-01T00:12:34+00:00") << Qt::ISODate << QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::UTC); + QTest::newRow("ISO -03") << QString::fromLatin1("2014-12-15T12:37:09-03") + << Qt::ISODate << QDateTime(QDate(2014, 12, 15), QTime(15, 37, 9), Qt::UTC); + QTest::newRow("ISO zzz-03") << QString::fromLatin1("2014-12-15T12:37:09.745-03") + << Qt::ISODate << QDateTime(QDate(2014, 12, 15), QTime(15, 37, 9, 745), Qt::UTC); + QTest::newRow("ISO -3") << QString::fromLatin1("2014-12-15T12:37:09-3") + << Qt::ISODate << QDateTime(QDate(2014, 12, 15), QTime(15, 37, 9), Qt::UTC); + QTest::newRow("ISO zzz-3") << QString::fromLatin1("2014-12-15T12:37:09.745-3") + << Qt::ISODate << QDateTime(QDate(2014, 12, 15), QTime(15, 37, 9, 745), Qt::UTC); // No time specified - defaults to Qt::LocalTime. QTest::newRow("ISO data3") << QString::fromLatin1("2002-10-01") << Qt::ISODate << QDateTime(QDate(2002, 10, 1), QTime(0, 0, 0, 0), Qt::LocalTime); diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/qtextboundaryfinder.pro b/tests/auto/corelib/tools/qtextboundaryfinder/qtextboundaryfinder.pro index 498d8f9c40..29b9854ebb 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/qtextboundaryfinder.pro +++ b/tests/auto/corelib/tools/qtextboundaryfinder/qtextboundaryfinder.pro @@ -5,3 +5,8 @@ SOURCES = tst_qtextboundaryfinder.cpp TESTDATA += data DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android: !android-no-sdk { + RESOURCES += \ + testdata.qrc +} diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/testdata.qrc b/tests/auto/corelib/tools/qtextboundaryfinder/testdata.qrc new file mode 100644 index 0000000000..0cc4ccaa57 --- /dev/null +++ b/tests/auto/corelib/tools/qtextboundaryfinder/testdata.qrc @@ -0,0 +1,8 @@ +<RCC> + <qresource prefix="/"> + <file>data/GraphemeBreakTest.txt</file> + <file>data/LineBreakTest.txt</file> + <file>data/SentenceBreakTest.txt</file> + <file>data/WordBreakTest.txt</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp index f97b8a4df8..0f7c42c122 100644 --- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp +++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp @@ -109,14 +109,35 @@ void tst_QVersionNumber::singleInstanceData() QTest::newRow("0.1.2alpha") << (QVector<int>() << 0 << 1 << 2) << QVersionNumber(0, 1, 2) << QStringLiteral("0.1.2") << QStringLiteral("0.1.2alpha") << 5 << false; QTest::newRow("0.1.2-alpha") << (QVector<int>() << 0 << 1 << 2) << QVersionNumber(0, 1, 2) << QStringLiteral("0.1.2") << QStringLiteral("0.1.2-alpha") << 5 << false; QTest::newRow("0.1.2.alpha") << (QVector<int>() << 0 << 1 << 2) << QVersionNumber(0, 1, 2) << QStringLiteral("0.1.2") << QStringLiteral("0.1.2.alpha") << 5 << false; + QTest::newRow("0.1.2.3alpha") << (QVector<int>() << 0 << 1 << 2 << 3) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3) << QStringLiteral("0.1.2.3") << QStringLiteral("0.1.2.3alpha") << 7 << false; + QTest::newRow("0.1.2.3.alpha") << (QVector<int>() << 0 << 1 << 2 << 3) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3) << QStringLiteral("0.1.2.3") << QStringLiteral("0.1.2.3.alpha") << 7 << false; QTest::newRow("0.1.2.3.4.alpha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4.alpha") << 9 << false; QTest::newRow("0.1.2.3.4 alpha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4 alpha") << 9 << false; QTest::newRow("0.1.2.3.4 alp ha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4 alp ha") << 9 << false; QTest::newRow("0.1.2.3.4alp ha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4alp ha") << 9 << false; QTest::newRow("0.1.2.3.4alpha ") << (QVector<int>() << 0 << 1 << 2 << 3 << 4) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4alpha ") << 9 << false; + QTest::newRow("0.1.2.3.4.5alpha ") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5) << QStringLiteral("0.1.2.3.4.5") << QStringLiteral("0.1.2.3.4.5alpha ") << 11 << false; + QTest::newRow("0.1.2.3.4.5.6alpha ") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6) << QStringLiteral("0.1.2.3.4.5.6") << QStringLiteral("0.1.2.3.4.5.6alpha ") << 13 << false; + QTest::newRow("0.1.2.3.4.5.6.7alpha ") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7) << QStringLiteral("0.1.2.3.4.5.6.7") << QStringLiteral("0.1.2.3.4.5.6.7alpha ") << 15 << false; + QTest::newRow("0.1.2.3.4.5.6.7.8alpha ") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8alpha ") << 17 << false; + QTest::newRow("0.1.2.3.4.5.6.7.8.alpha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8.alpha") << 17 << false; + QTest::newRow("0.1.2.3.4.5.6.7.8 alpha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8 alpha") << 17 << false; + QTest::newRow("0.1.2.3.4.5.6.7.8 alp ha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8 alp ha") << 17 << false; + QTest::newRow("0.1.2.3.4.5.6.7.8alp ha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8alp ha") << 17 << false; QTest::newRow("10.09") << (QVector<int>() << 10 << 9) << QVersionNumber(QVector<int>() << 10 << 9) << QStringLiteral("10.9") << QStringLiteral("10.09") << 5 << false; QTest::newRow("10.0x") << (QVector<int>() << 10 << 0) << QVersionNumber(QVector<int>() << 10 << 0) << QStringLiteral("10.0") << QStringLiteral("10.0x") << 4 << false; QTest::newRow("10.0xTest") << (QVector<int>() << 10 << 0) << QVersionNumber(QVector<int>() << 10 << 0) << QStringLiteral("10.0") << QStringLiteral("10.0xTest") << 4 << false; + QTest::newRow("127.09") << (QVector<int>() << 127 << 9) << QVersionNumber(QVector<int>() << 127 << 9) << QStringLiteral("127.9") << QStringLiteral("127.09") << 6 << false; + QTest::newRow("127.0x") << (QVector<int>() << 127 << 0) << QVersionNumber(QVector<int>() << 127 << 0) << QStringLiteral("127.0") << QStringLiteral("127.0x") << 5 << false; + QTest::newRow("127.0xTest") << (QVector<int>() << 127 << 0) << QVersionNumber(QVector<int>() << 127 << 0) << QStringLiteral("127.0") << QStringLiteral("127.0xTest") << 5 << false; + QTest::newRow("128.09") << (QVector<int>() << 128 << 9) << QVersionNumber(QVector<int>() << 128 << 9) << QStringLiteral("128.9") << QStringLiteral("128.09") << 6 << false; + QTest::newRow("128.0x") << (QVector<int>() << 128 << 0) << QVersionNumber(QVector<int>() << 128 << 0) << QStringLiteral("128.0") << QStringLiteral("128.0x") << 5 << false; + QTest::newRow("128.0xTest") << (QVector<int>() << 128 << 0) << QVersionNumber(QVector<int>() << 128 << 0) << QStringLiteral("128.0") << QStringLiteral("128.0xTest") << 5 << false; +} + +namespace UglyOperator { +// ugh, but the alternative (operator <<) is even worse... +static inline QVector<int> operator+(QVector<int> v, int i) { v.push_back(i); return qMove(v); } } void tst_QVersionNumber::comparisonData() @@ -141,6 +162,7 @@ void tst_QVersionNumber::comparisonData() QTest::newRow("1.0, 1.0") << QVersionNumber(1, 0) << QVersionNumber(1, 0) << true << false << false << true << false << true << 0 << true << QVersionNumber(1, 0); QTest::newRow("1, 1.0") << QVersionNumber(1) << QVersionNumber(1, 0) << false << true << true << true << false << false << -1 << true << QVersionNumber(1); QTest::newRow("1.0, 1") << QVersionNumber(1, 0) << QVersionNumber(1) << false << true << false << false << true << true << 1 << false << QVersionNumber(1); + QTest::newRow("0.1.2, 0.1") << QVersionNumber(0, 1, 2) << QVersionNumber(0, 1) << false << true << false << false << true << true << 2 << false << QVersionNumber(0, 1); QTest::newRow("0.1, 0.1.2") << QVersionNumber(0, 1) << QVersionNumber(0, 1, 2) << false << true << true << true << false << false << -2 << true << QVersionNumber(0, 1); QTest::newRow("0.1.2, 0.1.2") << QVersionNumber(0, 1, 2) << QVersionNumber(0, 1, 2) << true << false << false << true << false << true << 0 << true << QVersionNumber(0, 1, 2); @@ -152,6 +174,44 @@ void tst_QVersionNumber::comparisonData() QTest::newRow("0.-1, 0.1") << QVersionNumber(0, -1) << QVersionNumber(0, 1) << false << true << true << true << false << false << -2 << false << QVersionNumber(0); QTest::newRow("0.-1, 0") << QVersionNumber(0, -1) << QVersionNumber(0) << false << true << true << true << false << false << -1 << false << QVersionNumber(0); QTest::newRow("0, 0.-1") << QVersionNumber(0) << QVersionNumber(0, -1) << false << true << false << false << true << true << 1 << true << QVersionNumber(0); + + QTest::newRow("0.127.2, 0.127") << QVersionNumber(0, 127, 2) << QVersionNumber(0, 127) << false << true << false << false << true << true << 2 << false << QVersionNumber(0, 127); + QTest::newRow("0.127, 0.127.2") << QVersionNumber(0, 127) << QVersionNumber(0, 127, 2) << false << true << true << true << false << false << -2 << true << QVersionNumber(0, 127); + QTest::newRow("0.127.2, 0.127.2") << QVersionNumber(0, 127, 2) << QVersionNumber(0, 127, 2) << true << false << false << true << false << true << 0 << true << QVersionNumber(0, 127, 2); + QTest::newRow("0.127.2, 127.127.2") << QVersionNumber(0, 127, 2) << QVersionNumber(127, 127, 2) << false << true << true << true << false << false << -127 << false << QVersionNumber(); + QTest::newRow("127.127.2, 0.127.2") << QVersionNumber(127, 127, 2) << QVersionNumber(0, 127, 2) << false << true << false << false << true << true << 127 << false << QVersionNumber(); + QTest::newRow("127, -128") << QVersionNumber(127) << QVersionNumber(-128) << false << true << false << false << true << true << 255 << false << QVersionNumber(); + QTest::newRow("-128, 127") << QVersionNumber(-128) << QVersionNumber(127) << false << true << true << true << false << false << -255 << false << QVersionNumber(); + QTest::newRow("0.127, 0.-128") << QVersionNumber(0, 127) << QVersionNumber(0, -128) << false << true << false << false << true << true << 255 << false << QVersionNumber(0); + QTest::newRow("0.-128, 0.127") << QVersionNumber(0, -128) << QVersionNumber(0, 127) << false << true << true << true << false << false << -255 << false << QVersionNumber(0); + QTest::newRow("0.-128, 0") << QVersionNumber(0, -128) << QVersionNumber(0) << false << true << true << true << false << false << -128 << false << QVersionNumber(0); + QTest::newRow("0, 0.-128") << QVersionNumber(0) << QVersionNumber(0, -128) << false << true << false << false << true << true << 128 << true << QVersionNumber(0); + + QTest::newRow("0.128.2, 0.128") << QVersionNumber(0, 128, 2) << QVersionNumber(0, 128) << false << true << false << false << true << true << 2 << false << QVersionNumber(0, 128); + QTest::newRow("0.128, 0.128.2") << QVersionNumber(0, 128) << QVersionNumber(0, 128, 2) << false << true << true << true << false << false << -2 << true << QVersionNumber(0, 128); + QTest::newRow("0.128.2, 0.128.2") << QVersionNumber(0, 128, 2) << QVersionNumber(0, 128, 2) << true << false << false << true << false << true << 0 << true << QVersionNumber(0, 128, 2); + QTest::newRow("0.128.2, 128.128.2") << QVersionNumber(0, 128, 2) << QVersionNumber(128, 128, 2) << false << true << true << true << false << false << -128 << false << QVersionNumber(); + QTest::newRow("128.128.2, 0.128.2") << QVersionNumber(128, 128, 2) << QVersionNumber(0, 128, 2) << false << true << false << false << true << true << 128 << false << QVersionNumber(); + QTest::newRow("128, -129") << QVersionNumber(128) << QVersionNumber(-129) << false << true << false << false << true << true << 257 << false << QVersionNumber(); + QTest::newRow("-129, 128") << QVersionNumber(-129) << QVersionNumber(128) << false << true << true << true << false << false << -257 << false << QVersionNumber(); + QTest::newRow("0.128, 0.-129") << QVersionNumber(0, 128) << QVersionNumber(0, -129) << false << true << false << false << true << true << 257 << false << QVersionNumber(0); + QTest::newRow("0.-129, 0.128") << QVersionNumber(0, -129) << QVersionNumber(0, 128) << false << true << true << true << false << false << -257 << false << QVersionNumber(0); + QTest::newRow("0.-129, 0") << QVersionNumber(0, -129) << QVersionNumber(0) << false << true << true << true << false << false << -129 << false << QVersionNumber(0); + QTest::newRow("0, 0.-129") << QVersionNumber(0) << QVersionNumber(0, -129) << false << true << false << false << true << true << 129 << true << QVersionNumber(0); + + const QVector<int> common = QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6; + using namespace UglyOperator; + QTest::newRow("0.1.2.3.4.5.6.0.1.2, 0.1.2.3.4.5.6.0.1") << QVersionNumber(common + 0 + 1 + 2) << QVersionNumber(common + 0 + 1) << false << true << false << false << true << true << 2 << false << QVersionNumber(common + 0 + 1); + QTest::newRow("0.1.2.3.4.5.6.0.1, 0.1.2.3.4.5.6.0.1.2") << QVersionNumber(common + 0 + 1) << QVersionNumber(common + 0 + 1 + 2) << false << true << true << true << false << false << -2 << true << QVersionNumber(common + 0 + 1); + QTest::newRow("0.1.2.3.4.5.6.0.1.2, 0.1.2.3.4.5.6.0.1.2") << QVersionNumber(common + 0 + 1 + 2) << QVersionNumber(common + 0 + 1 + 2) << true << false << false << true << false << true << 0 << true << QVersionNumber(common + 0 + 1 + 2); + QTest::newRow("0.1.2.3.4.5.6.0.1.2, 0.1.2.3.4.5.6.1.1.2") << QVersionNumber(common + 0 + 1 + 2) << QVersionNumber(common + 1 + 1 + 2) << false << true << true << true << false << false << -1 << false << QVersionNumber(common); + QTest::newRow("0.1.2.3.4.5.6.1.1.2, 0.1.2.3.4.5.6.0.1.2") << QVersionNumber(common + 1 + 1 + 2) << QVersionNumber(common + 0 + 1 + 2) << false << true << false << false << true << true << 1 << false << QVersionNumber(common); + QTest::newRow("0.1.2.3.4.5.6.1, 0.1.2.3.4.5.6.-1") << QVersionNumber(common + 1) << QVersionNumber(common + -1) << false << true << false << false << true << true << 2 << false << QVersionNumber(common); + QTest::newRow("0.1.2.3.4.5.6.-1, 0.1.2.3.4.5.6.1") << QVersionNumber(common + -1) << QVersionNumber(common + 1) << false << true << true << true << false << false << -2 << false << QVersionNumber(common); + QTest::newRow("0.1.2.3.4.5.6.0.1, 0.1.2.3.4.5.6.0.-1") << QVersionNumber(common + 0 + 1) << QVersionNumber(common + 0 + -1) << false << true << false << false << true << true << 2 << false << QVersionNumber(common + 0); + QTest::newRow("0.1.2.3.4.5.6.0.-1, 0.1.2.3.4.5.6.0.1") << QVersionNumber(common + 0 + -1) << QVersionNumber(common + 0 + 1) << false << true << true << true << false << false << -2 << false << QVersionNumber(common + 0); + QTest::newRow("0.1.2.3.4.5.6.0.-1, 0.1.2.3.4.5.6.0") << QVersionNumber(common + 0 + -1) << QVersionNumber(common + 0) << false << true << true << true << false << false << -1 << false << QVersionNumber(common + 0); + QTest::newRow("0.1.2.3.4.5.6.0, 0.1.2.3.4.5.6.0.-1") << QVersionNumber(common + 0) << QVersionNumber(common + 0 + -1) << false << true << false << false << true << true << 1 << true << QVersionNumber(common + 0); } void tst_QVersionNumber::initTestCase() |