diff options
Diffstat (limited to 'tests/auto/corelib')
10 files changed, 63 insertions, 43 deletions
diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp index bf43f6d710..2195bf8ec8 100644 --- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp +++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp @@ -34,11 +34,9 @@ #include <private/qrandom_p.h> #include <algorithm> -#if QT_CONFIG(cxx11_random) -# include <random> -#endif +#include <random> -#if !QT_CONFIG(getentropy) && (QT_CONFIG(cxx11_random) || defined(Q_OS_BSD4) || defined(Q_OS_WIN)) +#if !QT_CONFIG(getentropy) && (defined(Q_OS_BSD4) || defined(Q_OS_WIN)) # define HAVE_FALLBACK_ENGINE #endif @@ -468,9 +466,6 @@ template <typename Engine> void seedStdRandomEngine() void tst_QRandomGenerator::seedStdRandomEngines() { -#if !QT_CONFIG(cxx11_random) - QSKIP("<random> not found"); -#else seedStdRandomEngine<std::default_random_engine>(); seedStdRandomEngine<std::minstd_rand0>(); seedStdRandomEngine<std::minstd_rand>(); @@ -480,7 +475,6 @@ void tst_QRandomGenerator::seedStdRandomEngines() seedStdRandomEngine<std::ranlux48_base>(); seedStdRandomEngine<std::ranlux24>(); seedStdRandomEngine<std::ranlux48>(); -#endif } void tst_QRandomGenerator::stdUniformIntDistribution_data() @@ -511,9 +505,6 @@ void tst_QRandomGenerator::stdUniformIntDistribution_data() void tst_QRandomGenerator::stdUniformIntDistribution() { -#if !QT_CONFIG(cxx11_random) - QSKIP("<random> not found"); -#else QFETCH(uint, control); QFETCH(quint32, max); setRNGControl(control & (SkipHWRNG|SkipSystemRNG|SkipMemfill)); @@ -575,14 +566,11 @@ void tst_QRandomGenerator::stdUniformIntDistribution() QVERIFY(value <= dist.max()); } } -#endif } void tst_QRandomGenerator::stdGenerateCanonical() { -#if !QT_CONFIG(cxx11_random) - QSKIP("<random> not found"); -#elif defined(Q_CC_MSVC) && Q_CC_MSVC < 1900 +#if defined(Q_CC_MSVC) && Q_CC_MSVC < 1900 // see https://connect.microsoft.com/VisualStudio/feedback/details/811611 QSKIP("MSVC 2013's std::generate_canonical is broken"); #else @@ -634,9 +622,6 @@ void tst_QRandomGenerator::stdUniformRealDistribution_data() void tst_QRandomGenerator::stdUniformRealDistribution() { -#if !QT_CONFIG(cxx11_random) - QSKIP("<random> not found"); -#else QFETCH(uint, control); QFETCH(double, min); QFETCH(double, sup); @@ -663,14 +648,10 @@ void tst_QRandomGenerator::stdUniformRealDistribution() QVERIFY(value < dist.max()); } } -#endif } void tst_QRandomGenerator::stdRandomDistributions() { -#if !QT_CONFIG(cxx11_random) - QSKIP("<random> not found"); -#else // just a compile check for some of the distributions, besides // std::uniform_int_distribution and std::uniform_real_distribution (tested // above) @@ -695,7 +676,6 @@ void tst_QRandomGenerator::stdRandomDistributions() QVERIFY(discrete(rd) != 0); QVERIFY_3TIMES(discrete(rd) == 3); } -#endif } QTEST_APPLESS_MAIN(tst_QRandomGenerator) 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 f10c2a7c98..e086bf1904 100644 --- a/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp +++ b/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp @@ -31,6 +31,12 @@ #include <QLockFile> #include <QThread> +#ifdef Q_OS_UNIX +# include <unistd.h> +#else +# include <stdlib.h> +#endif + int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); @@ -44,11 +50,11 @@ int main(int argc, char *argv[]) if (argc > 2) option = QString::fromLocal8Bit(argv[2]); - if (option == "-crash") { + if (option == "-uncleanexit") { QLockFile lockFile(lockName); lockFile.lock(); // exit on purpose, so that the lock remains! - exit(0); + _exit(0); } else if (option == "-busy") { QLockFile lockFile(lockName); lockFile.lock(); diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index d2f345feb5..835c4a2778 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -262,7 +262,7 @@ void tst_QLockFile::staleLockFromCrashedProcess() QFETCH(int, staleLockTime); const QString fileName = dir.path() + "/staleLockFromCrashedProcess"; - int ret = QProcess::execute(m_helperApp, QStringList() << fileName << "-crash"); + int ret = QProcess::execute(m_helperApp, QStringList() << fileName << "-uncleanexit"); QCOMPARE(ret, int(QLockFile::NoError)); QTRY_VERIFY(QFile::exists(fileName)); @@ -288,7 +288,7 @@ void tst_QLockFile::staleLockFromCrashedProcessReusedPid() #else const QString fileName = dir.path() + "/staleLockFromCrashedProcessReusedPid"; - int ret = QProcess::execute(m_helperApp, QStringList() << fileName << "-crash"); + int ret = QProcess::execute(m_helperApp, QStringList() << fileName << "-uncleanexit"); QCOMPARE(ret, int(QLockFile::NoError)); QVERIFY(QFile::exists(fileName)); QVERIFY(overwritePidInLockFile(fileName, QCoreApplication::applicationPid())); @@ -397,7 +397,7 @@ void tst_QLockFile::staleLockRace() // Only one thread should delete it, otherwise a race will ensue const QString fileName = dir.path() + "/sharedFile"; const QString lockName = fileName + ".lock"; - int ret = QProcess::execute(m_helperApp, QStringList() << lockName << "-crash"); + int ret = QProcess::execute(m_helperApp, QStringList() << lockName << "-uncleanexit"); QCOMPARE(ret, int(QLockFile::NoError)); QTRY_VERIFY(QFile::exists(lockName)); diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 74e9e4e47d..b0dd7f18f1 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -3893,7 +3893,7 @@ void tst_QSortFilterProxyModel::hierarchyFilterInvalidation() view.setCurrentIndex(proxy.index(2, 0).child(0, 0)); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); proxy.setMode(true); } @@ -3950,7 +3950,7 @@ void tst_QSortFilterProxyModel::simpleFilterInvalidation() view.setModel(&proxy); view.show(); - QTest::qWaitForWindowExposed(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); proxy.setMode(true); model.insertRow(0, new QStandardItem("extra")); diff --git a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro index e37542be65..1a76085c1b 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro +++ b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro @@ -5,5 +5,5 @@ SOURCES = tst_qcoreapplication.cpp HEADERS = tst_qcoreapplication.h win32: VERSION = 1.2.3.4 else: VERSION = 1.2.3 -darwin: QMAKE_LFLAGS += -Wl,-sectcreate,__TEXT,__info_plist,$$shell_quote($$PWD/Info.plist) +QMAKE_INFO_PLIST = $$PWD/Info.plist requires(qtConfig(private_tests)) diff --git a/tests/auto/corelib/kernel/qtimer/qtimer.pro b/tests/auto/corelib/kernel/qtimer/qtimer.pro index b27d862bc5..710dfea682 100644 --- a/tests/auto/corelib/kernel/qtimer/qtimer.pro +++ b/tests/auto/corelib/kernel/qtimer/qtimer.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qtimer -QT = core testlib +QT = core core-private testlib SOURCES = tst_qtimer.cpp # Force C++17 if available diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 343a9384bc..2c6d9ea7c0 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -33,11 +33,11 @@ # include <QtCore/QCoreApplication> #endif +#include <QtCore/private/qglobal_p.h> #include <QtTest/QtTest> #include <qtimer.h> #include <qthread.h> -#include <qoperatingsystemversion.h> #if defined Q_OS_UNIX #include <unistd.h> @@ -500,7 +500,7 @@ void tst_QTimer::moveToThread() #if defined(Q_OS_WIN32) QSKIP("Does not work reliably on Windows :("); #elif defined(Q_OS_MACOS) - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSSierra) + if (__builtin_available(macOS 10.12, *)) QSKIP("Does not work reliably on macOS 10.12 (QTBUG-59679)"); #endif QTimer ti1; diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp index 304f6121a5..15a39b62c0 100644 --- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp +++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp @@ -41,6 +41,7 @@ protected slots: void simple_activated(); void simple_timerSet(); private slots: + void simple_data(); void simple(); void manyNotifiers(); @@ -61,9 +62,17 @@ void tst_QWinEventNotifier::simple_timerSet() SetEvent((HANDLE)simpleHEvent); } +void tst_QWinEventNotifier::simple_data() +{ + QTest::addColumn<bool>("resetManually"); + QTest::newRow("manual_reset") << true; + QTest::newRow("auto_reset") << false; +} + void tst_QWinEventNotifier::simple() { - simpleHEvent = CreateEvent(0, true, false, 0); + QFETCH(bool, resetManually); + simpleHEvent = CreateEvent(0, resetManually, false, 0); QVERIFY(simpleHEvent); QWinEventNotifier n(simpleHEvent); diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 27a617ec85..0405896ca7 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -1338,7 +1338,7 @@ void tst_QThread::quitLock() void tst_QThread::create() { -#ifndef QTHREAD_HAS_CREATE +#if !QT_CONFIG(cxx11_future) QSKIP("This test requires QThread::create"); #else { @@ -1586,7 +1586,7 @@ void tst_QThread::create() } #endif // QT_NO_EXCEPTIONS #endif // QTHREAD_HAS_VARIADIC_CREATE -#endif // QTHREAD_HAS_CREATE +#endif // QT_CONFIG(cxx11_future) } class StopableJob : public QObject diff --git a/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp b/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp index 48ea5a794c..4174b85f4c 100644 --- a/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp @@ -364,14 +364,21 @@ void tst_QStringView::basics() const void tst_QStringView::literals() const { #if !defined(Q_OS_WIN) || defined(Q_COMPILER_UNICODE_STRINGS) - // the + ensures it's a pointer, not an array - QCOMPARE(QStringView(+u"Hello").size(), 5); - QStringView sv = u"Hello"; + const char16_t hello[] = u"Hello"; + const char16_t longhello[] = + u"Hello World. This is a much longer message, to exercise qustrlen."; + const char16_t withnull[] = u"a\0zzz"; #else // storage_type is wchar_t - // the + ensures it's a pointer, not an array - QCOMPARE(QStringView(+L"Hello").size(), 5); - QStringView sv = L"Hello"; + const wchar_t hello[] = L"Hello"; + const wchar_t longhello[] = + L"Hello World. This is a much longer message, to exercise qustrlen."; + const wchar_t withnull[] = L"a\0zzz"; #endif + Q_STATIC_ASSERT(sizeof(longhello) >= 16); + + QCOMPARE(QStringView(hello).size(), 5); + QCOMPARE(QStringView(hello + 0).size(), 5); // forces decay to pointer + QStringView sv = hello; QCOMPARE(sv.size(), 5); QVERIFY(!sv.empty()); QVERIFY(!sv.isEmpty()); @@ -390,6 +397,24 @@ void tst_QStringView::literals() const QVERIFY(!sv2.isNull()); QVERIFY(!sv2.empty()); QCOMPARE(sv2.size(), 5); + + QStringView sv3(longhello); + QCOMPARE(size_t(sv3.size()), sizeof(longhello)/sizeof(longhello[0]) - 1); + QCOMPARE(sv3.last(), QLatin1Char('.')); + sv3 = longhello; + QCOMPARE(size_t(sv3.size()), sizeof(longhello)/sizeof(longhello[0]) - 1); + + for (int i = 0; i < sv3.size(); ++i) { + QStringView sv4(longhello + i); + QCOMPARE(size_t(sv4.size()), sizeof(longhello)/sizeof(longhello[0]) - 1 - i); + QCOMPARE(sv4.last(), QLatin1Char('.')); + sv4 = longhello + i; + QCOMPARE(size_t(sv4.size()), sizeof(longhello)/sizeof(longhello[0]) - 1 - i); + } + + // these are different results + QCOMPARE(size_t(QStringView(withnull).size()), sizeof(withnull)/sizeof(withnull[0]) - 1); + QCOMPARE(QStringView(withnull + 0).size(), 1); } void tst_QStringView::at() const |