diff options
67 files changed, 825 insertions, 436 deletions
diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in index 309798a767..db18dbece6 100644 --- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in @@ -419,14 +419,6 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME}) !!ENDIF !!ENDIF - # Add a versionless target, for compatibility with Qt6. - if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::$${CMAKE_MODULE_NAME}) - add_library(Qt::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED) - set_target_properties(Qt::$${CMAKE_MODULE_NAME} PROPERTIES - INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}\" - ) - endif() - !!IF !equals(TEMPLATE, aux) !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK) set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1) @@ -648,3 +640,11 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME}) _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}ConfigVersion.cmake\") endif() + +# Add a versionless target, for compatibility with Qt6. +if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND TARGET Qt5::$${CMAKE_MODULE_NAME} AND NOT TARGET Qt::$${CMAKE_MODULE_NAME}) + add_library(Qt::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED) + set_target_properties(Qt::$${CMAKE_MODULE_NAME} PROPERTIES + INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}\" + ) +endif() diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index 9789c9c8e5..0412b52813 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -1560,7 +1560,7 @@ std::pair<bool, QString> UnixMakefileGenerator::writeObjectsPart(QTextStream &t, objectsLinkLine = "$(OBJECTS)"; } else { QString ld_response_file = fileVar("OBJECTS_DIR"); - ld_response_file += var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET"); + ld_response_file += var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("QMAKE_TARGET"); if (!var("BUILD_NAME").isEmpty()) ld_response_file += "." + var("BUILD_NAME"); if (!var("MAKEFILE").isEmpty()) diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 76ecbe043b..f408d65895 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -157,6 +157,11 @@ public class QtNative } } + public static String[] getStringArray(String joinedString) + { + return joinedString.split(","); + } + private static Uri getUriWithValidPermission(Context context, String uri, String openMode) { try { diff --git a/src/corelib/doc/snippets/hellotrmain.cpp b/src/corelib/doc/snippets/hellotrmain.cpp index 721a83240b..526da44701 100644 --- a/src/corelib/doc/snippets/hellotrmain.cpp +++ b/src/corelib/doc/snippets/hellotrmain.cpp @@ -54,15 +54,15 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); QTranslator translator; - // look up e.g. :/translations/myapp_de.qm - if (translator.load(QLocale(), QLatin1String("myapp"), QLatin1String("_"), QLatin1String(":/translations"))) + // look up e.g. :/i18n/myapp_de.qm + if (translator.load(QLocale(), QLatin1String("myapp"), QLatin1String("_"), QLatin1String(":/i18n"))) QCoreApplication::installTranslator(&translator); QPushButton hello(QCoreApplication::translate("main", "Hello world!")); hello.resize(100, 30); hello.show(); - return QCoreApplication::exec(); + return app.exec(); } //! [0] diff --git a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp index a2597faa93..0e29714677 100644 --- a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp +++ b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp @@ -642,7 +642,7 @@ void QConcatenateTablesProxyModelPrivate::_q_slotSourceLayoutAboutToBeChanged(co layoutChangePersistentIndexes.reserve(persistentIndexList.size()); layoutChangeProxyIndexes.reserve(persistentIndexList.size()); - for (const QPersistentModelIndex &proxyPersistentIndex : persistentIndexList) { + for (const QModelIndex &proxyPersistentIndex : persistentIndexList) { layoutChangeProxyIndexes.append(proxyPersistentIndex); Q_ASSERT(proxyPersistentIndex.isValid()); const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp index f5684c6eda..8210e27f8a 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.cpp +++ b/src/corelib/itemmodels/qidentityproxymodel.cpp @@ -532,7 +532,7 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPe emit q->layoutAboutToBeChanged(parents, hint); const auto proxyPersistentIndexes = q->persistentIndexList(); - for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { + for (const QModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { proxyIndexes << proxyPersistentIndex; Q_ASSERT(proxyPersistentIndex.isValid()); const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); diff --git a/src/corelib/itemmodels/qtransposeproxymodel.cpp b/src/corelib/itemmodels/qtransposeproxymodel.cpp index 4853f90632..207faa6151 100644 --- a/src/corelib/itemmodels/qtransposeproxymodel.cpp +++ b/src/corelib/itemmodels/qtransposeproxymodel.cpp @@ -92,7 +92,7 @@ void QTransposeProxyModelPrivate::onLayoutAboutToBeChanged(const QList<QPersiste layoutChangePersistentIndexes.clear(); layoutChangeProxyIndexes.reserve(proxyPersistentIndexes.size()); layoutChangePersistentIndexes.reserve(proxyPersistentIndexes.size()); - for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { + for (const QModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { layoutChangeProxyIndexes << proxyPersistentIndex; Q_ASSERT(proxyPersistentIndex.isValid()); const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 2205366696..d7d670b5bc 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -341,8 +341,9 @@ public: Translation files are created using \l{Qt Linguist}. The most common use of QTranslator is to: load a translation - file, install it using QCoreApplication::installTranslator(), and use - it via QObject::tr(). Here's an example \c main() function using the + file, and install it using QCoreApplication::installTranslator(). + + Here's an example \c main() function using the QTranslator: \snippet hellotrmain.cpp 0 diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index f0c903737f..3da643dc8b 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -5097,20 +5097,28 @@ namespace QtPrivate { namespace DeprecatedRefClassBehavior { void warn(WarningType w, EmittingClass c) { - static const char deprecatedBehaviorString[] = + const char *deprecatedBehaviorString = "The corresponding behavior is deprecated, and will be changed" " in a future version of Qt."; const char *emittingClassName = nullptr; - const char *containerClassName = nullptr; switch (c) { case EmittingClass::QByteRef: emittingClassName = "QByteRef"; - containerClassName = "QByteArray"; break; case EmittingClass::QCharRef: emittingClassName = "QCharRef"; + break; + } + + const char *containerClassName = nullptr; + + switch (c) { + case EmittingClass::QByteRef: + containerClassName = "QByteArray"; + break; + case EmittingClass::QCharRef: containerClassName = "QString"; break; } @@ -5121,7 +5129,7 @@ void warn(WarningType w, EmittingClass c) emittingClassName, containerClassName, deprecatedBehaviorString); break; case WarningType::DelayedDetach: - qWarning("Using %s with on a %s that is not already detached. %s", + qWarning("Using %s on a %s that is not already detached. %s", emittingClassName, containerClassName, deprecatedBehaviorString); break; } diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index e74b825774..fac62c94a4 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -4509,7 +4509,7 @@ QStringList QLocale::uiLanguages() const if (!res.isNull()) { uiLanguages = res.toStringList(); // ... but we need to include likely-adjusted forms of each of those, too: - for (const auto entry : qAsConst(uiLanguages)) + for (const auto &entry : qAsConst(uiLanguages)) locales.append(QLocale(entry)); } if (locales.isEmpty()) diff --git a/src/corelib/text/qstringliteral.h b/src/corelib/text/qstringliteral.h index 2a7e607c63..ab2a5f83f7 100644 --- a/src/corelib/text/qstringliteral.h +++ b/src/corelib/text/qstringliteral.h @@ -69,8 +69,7 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, Q_STATIC_STRING_DATA_HEADER_INITIALIZER(Size), \ QT_UNICODE_LITERAL(str) }; \ QStringDataPtr holder = { qstring_literal.data_ptr() }; \ - const QString qstring_literal_temp(holder); \ - return qstring_literal_temp; \ + return QString(holder); \ }()) \ /**/ diff --git a/src/corelib/thread/qrunnable.h b/src/corelib/thread/qrunnable.h index 26b6b991ac..47ea00bdb0 100644 --- a/src/corelib/thread/qrunnable.h +++ b/src/corelib/thread/qrunnable.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QRunnable { - int ref; + int ref; // Qt6: Make this a bool, or make autoDelete() virtual. friend class QThreadPool; friend class QThreadPoolPrivate; diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index 44cdf071df..1f99bad247 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -88,7 +88,8 @@ void QThreadPoolThread::run() do { if (r) { - const bool autoDelete = r->autoDelete(); + const bool del = r->autoDelete(); + Q_ASSERT(!del || r->ref == 1); // run the task @@ -106,10 +107,10 @@ void QThreadPoolThread::run() throw; } #endif - locker.relock(); - if (autoDelete && !--r->ref) + if (del) delete r; + locker.relock(); } // if too many threads are active, expire this thread @@ -193,8 +194,6 @@ bool QThreadPoolPrivate::tryStart(QRunnable *task) ++activeThreads; - if (task->autoDelete()) - ++task->ref; thread->runnable = task; thread->start(); return true; @@ -213,9 +212,6 @@ inline bool comparePriority(int priority, const QueuePage *p) void QThreadPoolPrivate::enqueueTask(QRunnable *runnable, int priority) { Q_ASSERT(runnable != nullptr); - if (runnable->autoDelete()) - ++runnable->ref; - for (QueuePage *page : qAsConst(queue)) { if (page->priority() == priority && !page->isFull()) { page->push(runnable); @@ -269,8 +265,6 @@ void QThreadPoolPrivate::startThread(QRunnable *runnable) allThreads.insert(thread.data()); ++activeThreads; - if (runnable->autoDelete()) - ++runnable->ref; thread->runnable = runnable; thread.take()->start(); } @@ -334,8 +328,12 @@ void QThreadPoolPrivate::clear() for (QueuePage *page : qAsConst(queue)) { while (!page->isFinished()) { QRunnable *r = page->pop(); - if (r && r->autoDelete() && !--r->ref) + if (r && r->autoDelete()) { + Q_ASSERT(r->ref == 1); + locker.unlock(); delete r; + locker.relock(); + } } } qDeleteAll(queue); @@ -365,19 +363,19 @@ bool QThreadPool::tryTake(QRunnable *runnable) if (runnable == nullptr) return false; - { - QMutexLocker locker(&d->mutex); - - for (QueuePage *page : qAsConst(d->queue)) { - if (page->tryTake(runnable)) { - if (page->isFinished()) { - d->queue.removeOne(page); - delete page; - } - if (runnable->autoDelete()) - --runnable->ref; // undo ++ref in start() - return true; + + QMutexLocker locker(&d->mutex); + for (QueuePage *page : qAsConst(d->queue)) { + if (page->tryTake(runnable)) { + if (page->isFinished()) { + d->queue.removeOne(page); + delete page; } + if (runnable->autoDelete()) { + Q_ASSERT(runnable->ref == 1); + --runnable->ref; // undo ++ref in start() + } + return true; } } @@ -395,11 +393,12 @@ void QThreadPoolPrivate::stealAndRunRunnable(QRunnable *runnable) Q_Q(QThreadPool); if (!q->tryTake(runnable)) return; - const bool del = runnable->autoDelete() && !runnable->ref; // tryTake already deref'ed + const bool del = runnable->autoDelete(); runnable->run(); if (del) { + Q_ASSERT(runnable->ref == 0); // tryTake already deref'ed delete runnable; } } @@ -503,6 +502,11 @@ void QThreadPool::start(QRunnable *runnable, int priority) Q_D(QThreadPool); QMutexLocker locker(&d->mutex); + if (runnable->autoDelete()) { + Q_ASSERT(runnable->ref == 0); + ++runnable->ref; + } + if (!d->tryStart(runnable)) { d->enqueueTask(runnable, priority); @@ -548,9 +552,23 @@ bool QThreadPool::tryStart(QRunnable *runnable) if (!runnable) return false; + if (runnable->autoDelete()) { + Q_ASSERT(runnable->ref == 0); + ++runnable->ref; + } + Q_D(QThreadPool); QMutexLocker locker(&d->mutex); - return d->tryStart(runnable); + if (d->tryStart(runnable)) + return true; + + // Undo the reference above as we did not start the runnable and + // take over ownership. + if (runnable->autoDelete()) { + --runnable->ref; + Q_ASSERT(runnable->ref == 0); + } + return false; } /*! diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 8553f79d90..c2b741f7ca 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2533,7 +2533,6 @@ QT_WARNING_POP \row \li ap or a \li Interpret as an am/pm time. \e a/ap will match a lower-case version of either QLocale::amText() or QLocale::pmText(). - \row \li t \li the timezone (for example "CEST") \endtable All other input characters will be treated as text. Any non-empty sequence @@ -5478,8 +5477,15 @@ QT_WARNING_POP Uses the calendar \a cal if supplied, else Gregorian. - See QDate::fromString() and QTime::fromString() for the expressions - recognized in the format string to represent parts of the date and time. + In addition to the expressions, recognized in the format string to represent + parts of the date and time, by QDate::fromString() and QTime::fromString(), + this method supports: + + \table + \header \li Expression \li Output + \row \li t \li the timezone (for example "CEST") + \endtable + All other input characters will be treated as text. Any non-empty sequence of characters enclosed in single quotes will also be treated (stripped of the quotes) as text and not be interpreted as expressions. diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 3374b28b69..bc3d9b992e 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -525,7 +525,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) } break; case 't': - if (parserType != QMetaType::QTime) { + if (parserType == QMetaType::QDateTime) { const SectionNode sn = { TimeZoneSection, i - add, countRepeat(newFormat, i, 4), 0 }; newSectionNodes.append(sn); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index 48501f5271..a3d2a2f7c0 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -1063,18 +1063,23 @@ QString QCommandLineParser::helpText() const return d->helpText(false); } -static QString wrapText(const QString &names, int longestOptionNameString, const QString &description) +static QString wrapText(const QString &names, int optionNameMaxWidth, const QString &description) { const QLatin1Char nl('\n'); const QLatin1String indentation(" "); - if (description.isEmpty()) - return indentation + names + nl; - QString text = indentation + names.leftJustified(longestOptionNameString) + QLatin1Char(' '); - const int indent = text.length(); + // In case the list of option names is very long, wrap it as well + int nameIndex = 0; + auto nextNameSection = [&]() { + QString section = names.mid(nameIndex, optionNameMaxWidth); + nameIndex += section.size(); + return section; + }; + + QString text; int lineStart = 0; int lastBreakable = -1; - const int max = 79 - indent; + const int max = 79 - (indentation.size() + optionNameMaxWidth + 1); int x = 0; const int len = description.length(); @@ -1103,8 +1108,7 @@ static QString wrapText(const QString &names, int longestOptionNameString, const if (breakAt != -1) { const int numChars = breakAt - lineStart; //qDebug() << "breakAt=" << description.at(breakAt) << "breakAtSpace=" << breakAtSpace << lineStart << "to" << breakAt << description.mid(lineStart, numChars); - if (lineStart > 0) - text += QString(indent, QLatin1Char(' ')); + text += indentation + nextNameSection().leftJustified(optionNameMaxWidth) + QLatin1Char(' '); text += description.midRef(lineStart, numChars) + nl; x = 0; lastBreakable = -1; @@ -1115,6 +1119,10 @@ static QString wrapText(const QString &names, int longestOptionNameString, const } } + while (nameIndex < names.size()) { + text += indentation + nextNameSection() + nl; + } + return text; } @@ -1158,11 +1166,12 @@ QString QCommandLineParserPrivate::helpText(bool includeQtOptions) const longestOptionNameString = qMax(longestOptionNameString, optionNamesString.length()); } ++longestOptionNameString; + const int optionNameMaxWidth = qMin(50, longestOptionNameString); auto optionNameIterator = optionNameList.cbegin(); for (const QCommandLineOption &option : qAsConst(options)) { if (option.flags() & QCommandLineOption::HiddenFromHelp) continue; - text += wrapText(*optionNameIterator, longestOptionNameString, option.description()); + text += wrapText(*optionNameIterator, optionNameMaxWidth, option.description()); ++optionNameIterator; } if (!positionalArgumentDefinitions.isEmpty()) { @@ -1170,7 +1179,7 @@ QString QCommandLineParserPrivate::helpText(bool includeQtOptions) const text += nl; text += QCommandLineParser::tr("Arguments:") + nl; for (const PositionalArgumentDefinition &arg : positionalArgumentDefinitions) - text += wrapText(arg.name, longestOptionNameString, arg.description); + text += wrapText(arg.name, optionNameMaxWidth, arg.description); } return text; } diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 2646d298e9..499c527cfc 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2149,12 +2149,7 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format, QImage dest(src.size(), format); dest.setColorTable(clut); - QString textsKeys = src.text(); - const auto textKeyList = textsKeys.splitRef(QLatin1Char('\n'), Qt::SkipEmptyParts); - for (const auto &textKey : textKeyList) { - const auto textKeySplitted = textKey.split(QLatin1String(": ")); - dest.setText(textKeySplitted[0].toString(), textKeySplitted[1].toString()); - } + QImageData::get(dest)->text = QImageData::get(src)->text; int h = src.height(); int w = src.width(); diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 56824e5ee7..b11aa9d9d0 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -385,6 +385,7 @@ private: friend class QRasterPlatformPixmap; friend class QBlittablePlatformPixmap; friend class QPixmapCacheEntry; + friend struct QImageData; public: typedef QImageData * DataPtr; diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index 0930955f5a..03ec43eaf7 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -69,6 +69,9 @@ struct Q_GUI_EXPORT QImageData { // internal image data static QImageData *create(const QSize &size, QImage::Format format); static QImageData *create(uchar *data, int w, int h, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr); + static QImageData *get(QImage &img) noexcept { return img.d; } + static const QImageData *get(const QImage &img) noexcept { return img.d; } + QAtomicInt ref; int width; diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index f153557077..169b6b8869 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -2842,15 +2842,15 @@ static void QT_FASTCALL fetchTransformedBilinearARGB32PM_fast_rotate_helper(uint fy += fdy; ++b; } - uint *boundedEnd = end; \ - if (fdx > 0) \ - boundedEnd = qMin(boundedEnd, b + (max_fx - fx) / fdx); \ - else if (fdx < 0) \ - boundedEnd = qMin(boundedEnd, b + (min_fx - fx) / fdx); \ - if (fdy > 0) \ - boundedEnd = qMin(boundedEnd, b + (max_fy - fy) / fdy); \ - else if (fdy < 0) \ - boundedEnd = qMin(boundedEnd, b + (min_fy - fy) / fdy); \ + uint *boundedEnd = end; + if (fdx > 0) + boundedEnd = qMin(boundedEnd, b + (max_fx - fx) / fdx); + else if (fdx < 0) + boundedEnd = qMin(boundedEnd, b + (min_fx - fx) / fdx); + if (fdy > 0) + boundedEnd = qMin(boundedEnd, b + (max_fy - fy) / fdy); + else if (fdy < 0) + boundedEnd = qMin(boundedEnd, b + (min_fy - fy) / fdy); // until boundedEnd we can now have a fast middle part without boundary checks #if defined(__SSE2__) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index bac042c784..739a4d04e6 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -2845,7 +2845,7 @@ static bool RectInRegion(QRegionPrivate *region, int rx, int ry, uint rwidth, ui break; } } - return partIn ? ((ry <= prect->bottom()) ? RectanglePart : RectangleIn) : RectangleOut; + return partIn; } // END OF Region.c extract // START OF poly.h extract diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index b6046b0fc5..5005f120dd 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -757,10 +757,10 @@ Q_GUI_EXPORT void qt_addBitmapToPath(qreal x0, qreal y0, const uchar *image_data // set up edges for (int y = 0; y <= h; ++y) { for (int x = 0; x <= w; ++x) { - bool topLeft = (x == 0)|(y == 0) ? false : SET(x - 1, y - 1); - bool topRight = (x == w)|(y == 0) ? false : SET(x, y - 1); - bool bottomLeft = (x == 0)|(y == h) ? false : SET(x - 1, y); - bool bottomRight = (x == w)|(y == h) ? false : SET(x, y); + bool topLeft = (x == 0 || y == 0) ? false : SET(x - 1, y - 1); + bool topRight = (x == w || y == 0) ? false : SET(x, y - 1); + bool bottomLeft = (x == 0 || y == h) ? false : SET(x - 1, y); + bool bottomRight = (x == w || y == h) ? false : SET(x, y); GRID(x, y) = 0; if ((!topRight) & bottomRight) diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 9d70873590..a2b3c8dc76 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -105,13 +105,14 @@ public: bool sizeDirty; bool layoutDirty; + bool fullLayoutCompleted; QVector<QPointer<QTextFrame> > floats; }; QTextFrameData::QTextFrameData() : maximumWidth(QFIXED_MAX), - currentLayoutStruct(nullptr), sizeDirty(true), layoutDirty(true) + currentLayoutStruct(nullptr), sizeDirty(true), layoutDirty(true), fullLayoutCompleted(false) { } @@ -2943,7 +2944,7 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in QTextFrameData *fd = data(f); QFixed newContentsWidth; - bool fullLayout = false; + bool fullLayout = (f == document->rootFrame() && !fd->fullLayoutCompleted); { QTextFrameFormat fformat = f->frameFormat(); // set sizes of this frame from the format @@ -3397,6 +3398,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout cp.contentsWidth = layoutStruct->contentsWidth; checkPoints.append(cp); checkPoints.reserve(checkPoints.size()); + fd->fullLayoutCompleted = true; } else { currentLazyLayoutPosition = checkPoints.constLast().positionInFrame; // ####### @@ -3808,6 +3810,7 @@ void QTextDocumentLayout::documentChanged(int from, int oldLength, int length) d->contentHasAlignment = false; d->currentLazyLayoutPosition = 0; d->checkPoints.clear(); + data(d->docPrivate->rootFrame())->fullLayoutCompleted = false; d->layoutStep(); } else { d->ensureLayoutedByPosition(from); diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 6e87faf534..a2faa21172 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -704,7 +704,7 @@ QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QL if (notation == QDoubleValidator::StandardNotation) { double max = qMax(qAbs(q->b), qAbs(q->t)); - if (max < LLONG_MAX) { + if (max < double(LLONG_MAX)) { qlonglong n = pow10(numDigits(qlonglong(max))); // In order to get the highest possible number in the intermediate // range we need to get 10 to the power of the number of digits diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp index 22fdc5bb0b..4986b36ab1 100644 --- a/src/network/access/qnetworkaccesscachebackend.cpp +++ b/src/network/access/qnetworkaccesscachebackend.cpp @@ -123,6 +123,12 @@ bool QNetworkAccessCacheBackend::sendCacheContents() return true; } +bool QNetworkAccessCacheBackend::start() +{ + open(); + return true; +} + void QNetworkAccessCacheBackend::closeDownstreamChannel() { } diff --git a/src/network/access/qnetworkaccesscachebackend_p.h b/src/network/access/qnetworkaccesscachebackend_p.h index dfb0ce84d9..ceb02946dc 100644 --- a/src/network/access/qnetworkaccesscachebackend_p.h +++ b/src/network/access/qnetworkaccesscachebackend_p.h @@ -68,6 +68,7 @@ public: void open() override; void closeDownstreamChannel() override; void closeUpstreamChannel(); + bool start() override; void upstreamReadyRead(); void downstreamReadyWrite() override; diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 6f6aa73f62..d36cb46ce1 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -2116,7 +2116,10 @@ void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline) Q_Q(QNetworkAccessManager); if (statusMonitor.isEnabled()) { + auto previous = networkAccessible; networkAccessible = isOnline ? QNetworkAccessManager::Accessible : QNetworkAccessManager::NotAccessible; + if (previous != networkAccessible) + emit q->networkAccessibleChanged(networkAccessible); return; } diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp index af8b39bab6..5b84014789 100644 --- a/src/network/access/qnetworkreplywasmimpl.cpp +++ b/src/network/access/qnetworkreplywasmimpl.cpp @@ -245,7 +245,7 @@ void QNetworkReplyWasmImplPrivate::doSendRequest() attr.password = request.url().password().toUtf8(); } - attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY | EMSCRIPTEN_FETCH_PERSIST_FILE | EMSCRIPTEN_FETCH_REPLACE; + attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY; QNetworkRequest::CacheLoadControl CacheLoadControlAttribute = (QNetworkRequest::CacheLoadControl)request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(); diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index c95b1280b0..3ac54605e4 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -71,6 +71,7 @@ QT_BEGIN_NAMESPACE static QByteArray qNtlmPhase1(); static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phase2data); #if QT_CONFIG(sspi) // SSPI +static bool q_SSPI_library_load(); static QByteArray qSspiStartup(QAuthenticatorPrivate *ctx, QAuthenticatorPrivate::Method method, const QString& host); static QByteArray qSspiContinue(QAuthenticatorPrivate *ctx, QAuthenticatorPrivate::Method method, @@ -503,8 +504,13 @@ QByteArray QAuthenticatorPrivate::calculateResponse(const QByteArray &requestMet if (challenge.isEmpty()) { #if QT_CONFIG(sspi) // SSPI QByteArray phase1Token; - if (user.isEmpty()) // Only pull from system if no user was specified in authenticator + if (user.isEmpty()) { // Only pull from system if no user was specified in authenticator phase1Token = qSspiStartup(this, method, host); + } else if (!q_SSPI_library_load()) { + // Since we're not running qSspiStartup we have to make sure the library is loaded + qWarning("Failed to load the SSPI libraries"); + return ""; + } if (!phase1Token.isEmpty()) { response = phase1Token.toBase64(); phase = Phase2; diff --git a/src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp b/src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp index 7b5f2f16f8..2e29a22cf7 100644 --- a/src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp +++ b/src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp @@ -42,6 +42,10 @@ #include <androidjnimain.h> #include <jni.h> +#include <QMimeType> +#include <QMimeDatabase> +#include <QRegularExpression> + QT_BEGIN_NAMESPACE namespace QtAndroidFileDialogHelper { @@ -147,17 +151,47 @@ void QAndroidPlatformFileDialogHelper::setAllowMultipleSelections(bool allowMult allowMultipleSelections.object(), allowMultiple); } +QStringList nameFilterExtensions(const QString nameFilters) +{ + QStringList ret; +#if QT_CONFIG(regularexpression) + QRegularExpression re("(\\*\\.?\\w*)"); + QRegularExpressionMatchIterator i = re.globalMatch(nameFilters); + while (i.hasNext()) + ret << i.next().captured(1); +#endif // QT_CONFIG(regularexpression) + ret.removeAll("*"); + return ret; +} + void QAndroidPlatformFileDialogHelper::setMimeTypes() { + QStringList mimeTypes = options()->mimeTypeFilters(); + const QString nameFilter = options()->initiallySelectedNameFilter(); + + if (mimeTypes.isEmpty() && !nameFilter.isEmpty()) { + QMimeDatabase db; + for (const QString &filter : nameFilterExtensions(nameFilter)) + mimeTypes.append(db.mimeTypeForFile(filter).name()); + } + + QString type = !mimeTypes.isEmpty() ? mimeTypes.at(0) : QLatin1String("*/*"); m_intent.callObjectMethod("setType", "(Ljava/lang/String;)Landroid/content/Intent;", - QJNIObjectPrivate::fromString("*/*").object()); + QJNIObjectPrivate::fromString(type).object()); + + if (!mimeTypes.isEmpty()) { + const QJNIObjectPrivate extraMimeType = QJNIObjectPrivate::getStaticObjectField( + JniIntentClass, "EXTRA_MIME_TYPES", "Ljava/lang/String;"); + + QJNIObjectPrivate mimeTypesArray = QJNIObjectPrivate::callStaticObjectMethod( + "org/qtproject/qt5/android/QtNative", + "getStringArray", + "(Ljava/lang/String;)[Ljava/lang/String;", + QJNIObjectPrivate::fromString(mimeTypes.join(",")).object()); - const QJNIObjectPrivate extraMimeType = QJNIObjectPrivate::getStaticObjectField( - JniIntentClass, "EXTRA_MIME_TYPES", "Ljava/lang/String;"); - for (const QString &type : options()->mimeTypeFilters()) { m_intent.callObjectMethod( - "putExtra", "(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;", - extraMimeType.object(), QJNIObjectPrivate::fromString(type).object()); + "putExtra", "(Ljava/lang/String;[Ljava/lang/String;)Landroid/content/Intent;", + extraMimeType.object(), mimeTypesArray.object()); } } diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 069e9ce845..24e98f5bac 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1828,8 +1828,17 @@ void QCocoaWindow::updateNSToolbar() bool QCocoaWindow::testContentBorderAreaPosition(int position) const { - return isContentView() && m_drawContentBorderGradient && - 0 <= position && position < [m_view.window contentBorderThicknessForEdge:NSMaxYEdge]; + if (!m_drawContentBorderGradient || !isContentView()) + return false; + + // Determine if the given y postion (relative to the content area) is inside the + // unified toolbar area. Note that the value returned by contentBorderThicknessForEdge + // includes the title bar height; subtract it. + const int contentBorderThickness = [m_view.window contentBorderThicknessForEdge:NSMaxYEdge]; + const NSRect frameRect = m_view.window.frame; + const NSRect contentRect = [m_view.window contentRectForFrameRect:frameRect]; + const CGFloat titlebarHeight = frameRect.size.height - contentRect.size.height; + return 0 <= position && position < (contentBorderThickness - titlebarHeight); } qreal QCocoaWindow::devicePixelRatio() const diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 9aba658479..c3376c08e8 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -45,6 +45,7 @@ #include "qiosapplicationdelegate.h" #include "qiosviewcontroller.h" #include "quiview.h" +#include "qiostheme.h" #include <QtCore/private/qcore_mac_p.h> @@ -207,6 +208,18 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen) [super sendEvent:event]; } +- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection +{ + [super traitCollectionDidChange:previousTraitCollection]; + + if (self.screen == UIScreen.mainScreen) { + if (previousTraitCollection.userInterfaceStyle != self.traitCollection.userInterfaceStyle) { + QIOSTheme::initializeSystemPalette(); + QWindowSystemInterface::handleThemeChange<QWindowSystemInterface::SynchronousDelivery>(nullptr); + } + } +} + @end // ------------------------------------------------------------------------- diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index a3350bda87..19e476a064 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -416,6 +416,17 @@ if (unknownAction) return [super canPerformAction:action withSender:sender]; + + QObject *focusObject = QGuiApplication::focusObject(); + if (focusObject && focusObject->property("qt_im_readonly").toBool()) { + // exceptional menu items for read-only views: do include Copy, do not include Paste etc. + if (action == @selector(cut:) + || action == @selector(paste:) + || action == @selector(delete:)) + return NO; + if (action == @selector(copy:)) + return YES; + } return (hasSelection && isEditAction) || (!hasSelection && isSelectAction); } diff --git a/src/plugins/platforms/ios/qiostheme.h b/src/plugins/platforms/ios/qiostheme.h index c917679a91..c9d833713d 100644 --- a/src/plugins/platforms/ios/qiostheme.h +++ b/src/plugins/platforms/ios/qiostheme.h @@ -65,9 +65,12 @@ public: static const char *name; + static void initializeSystemPalette(); + private: mutable QHash<QPlatformTheme::Font, QFont *> m_fonts; - QPalette m_systemPalette; + + static QPalette s_systemPalette; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm index 5534264a60..626fbb66fe 100644 --- a/src/plugins/platforms/ios/qiostheme.mm +++ b/src/plugins/platforms/ios/qiostheme.mm @@ -44,6 +44,7 @@ #include <QtCore/private/qcore_mac_p.h> #include <QtGui/QFont> +#include <QtGui/private/qcoregraphics_p.h> #include <QtFontDatabaseSupport/private/qcoretextfontdatabase_p.h> #include <QtGui/private/qguiapplication_p.h> @@ -63,10 +64,8 @@ QT_BEGIN_NAMESPACE const char *QIOSTheme::name = "ios"; QIOSTheme::QIOSTheme() - : m_systemPalette(*QPlatformTheme::palette(QPlatformTheme::SystemPalette)) { - m_systemPalette.setBrush(QPalette::Highlight, QColor(204, 221, 237)); - m_systemPalette.setBrush(QPalette::HighlightedText, Qt::black); + initializeSystemPalette(); } QIOSTheme::~QIOSTheme() @@ -74,10 +73,41 @@ QIOSTheme::~QIOSTheme() qDeleteAll(m_fonts); } +QPalette QIOSTheme::s_systemPalette; + +void QIOSTheme::initializeSystemPalette() +{ + Q_DECL_IMPORT QPalette qt_fusionPalette(void); + s_systemPalette = qt_fusionPalette(); + + if (@available(ios 13.0, *)) { + s_systemPalette.setBrush(QPalette::Window, qt_mac_toQBrush(UIColor.systemGroupedBackgroundColor.CGColor)); + s_systemPalette.setBrush(QPalette::Active, QPalette::WindowText, qt_mac_toQBrush(UIColor.labelColor.CGColor)); + + s_systemPalette.setBrush(QPalette::Base, qt_mac_toQBrush(UIColor.secondarySystemGroupedBackgroundColor.CGColor)); + s_systemPalette.setBrush(QPalette::Active, QPalette::Text, qt_mac_toQBrush(UIColor.labelColor.CGColor)); + + s_systemPalette.setBrush(QPalette::Button, qt_mac_toQBrush(UIColor.secondarySystemBackgroundColor.CGColor)); + s_systemPalette.setBrush(QPalette::Active, QPalette::ButtonText, qt_mac_toQBrush(UIColor.labelColor.CGColor)); + + s_systemPalette.setBrush(QPalette::Active, QPalette::BrightText, qt_mac_toQBrush(UIColor.lightTextColor.CGColor)); + s_systemPalette.setBrush(QPalette::Active, QPalette::PlaceholderText, qt_mac_toQBrush(UIColor.placeholderTextColor.CGColor)); + + s_systemPalette.setBrush(QPalette::Active, QPalette::Link, qt_mac_toQBrush(UIColor.linkColor.CGColor)); + s_systemPalette.setBrush(QPalette::Active, QPalette::LinkVisited, qt_mac_toQBrush(UIColor.linkColor.CGColor)); + + s_systemPalette.setBrush(QPalette::Highlight, QColor(11, 70, 150, 60)); + s_systemPalette.setBrush(QPalette::HighlightedText, qt_mac_toQBrush(UIColor.labelColor.CGColor)); + } else { + s_systemPalette.setBrush(QPalette::Highlight, QColor(204, 221, 237)); + s_systemPalette.setBrush(QPalette::HighlightedText, Qt::black); + } +} + const QPalette *QIOSTheme::palette(QPlatformTheme::Palette type) const { if (type == QPlatformTheme::SystemPalette) - return &m_systemPalette; + return &s_systemPalette; return 0; } diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp index 13c39436ba..4b37367ad0 100644 --- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp +++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp @@ -107,6 +107,7 @@ public: { } WId winId = 0; + bool directoryMode = false; bool modal = false; bool multipleFiles = false; bool saveFile = false; @@ -145,6 +146,9 @@ void QXdgDesktopPortalFileDialog::initializeDialog() if (options()->fileMode() == QFileDialogOptions::ExistingFiles) d->multipleFiles = true; + if (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly) + d->directoryMode = true; + if (options()->isLabelExplicitlySet(QFileDialogOptions::Accept)) d->acceptLabel = options()->labelText(QFileDialogOptions::Accept); @@ -179,6 +183,7 @@ void QXdgDesktopPortalFileDialog::openPortal() options.insert(QLatin1String("modal"), d->modal); options.insert(QLatin1String("multiple"), d->multipleFiles); + options.insert(QLatin1String("directory"), d->directoryMode); if (d->saveFile) { if (!d->directory.isEmpty()) diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp index fb65f6d909..30c43b67dc 100644 --- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp +++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp @@ -45,6 +45,12 @@ #include <qpa/qplatformthemefactory_p.h> #include <qpa/qplatformintegration.h> +#include <QDBusConnection> +#include <QDBusMessage> +#include <QDBusPendingCall> +#include <QDBusPendingCallWatcher> +#include <QDBusPendingReply> + QT_BEGIN_NAMESPACE class QXdgDesktopPortalThemePrivate : public QPlatformThemePrivate @@ -60,6 +66,7 @@ public: } QPlatformTheme *baseTheme; + uint fileChooserPortalVersion = 0; }; QXdgDesktopPortalTheme::QXdgDesktopPortalTheme() @@ -90,6 +97,21 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme() // 3) Fall back on the built-in "null" platform theme. if (!d->baseTheme) d->baseTheme = new QPlatformTheme; + + // Get information about portal version + QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"), + QLatin1String("/org/freedesktop/portal/desktop"), + QLatin1String("org.freedesktop.DBus.Properties"), + QLatin1String("Get")); + message << QLatin1String("org.freedesktop.portal.FileChooser") << QLatin1String("version"); + QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall); + QObject::connect(watcher, &QDBusPendingCallWatcher::finished, [d] (QDBusPendingCallWatcher *watcher) { + QDBusPendingReply<QVariant> reply = *watcher; + if (reply.isValid()) { + d->fileChooserPortalVersion = reply.value().toUInt(); + } + }); } QPlatformMenuItem* QXdgDesktopPortalTheme::createPlatformMenuItem() const @@ -131,7 +153,9 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog Q_D(const QXdgDesktopPortalTheme); if (type == FileDialog) { - if (d->baseTheme->usePlatformNativeDialog(type)) + // Older versions of FileChooser portal don't support opening directories, therefore we fallback + // to native file dialog opened inside the sandbox to open a directory. + if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type)) return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type))); return new QXdgDesktopPortalFileDialog; diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 8e4aaa19c7..84233d6521 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -3977,13 +3977,19 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // which makes no sense on tabs. NSPopUpArrowPosition oldPosition = NSPopUpArrowAtCenter; NSPopUpButtonCell *pbCell = nil; - if (isPopupButton) { + auto rAdjusted = r; + if (isPopupButton && tp == QStyleOptionTab::OnlyOneTab) { pbCell = static_cast<NSPopUpButtonCell *>(pb.cell); oldPosition = pbCell.arrowPosition; pbCell.arrowPosition = NSPopUpNoArrow; + if (pb.state == NSOffState) { + // NSPopUpButton in this state is smaller. + rAdjusted.origin.x -= 3; + rAdjusted.size.width += 6; + } } - [pb.cell drawBezelWithFrame:r inView:pb.superview]; + [pb.cell drawBezelWithFrame:rAdjusted inView:pb.superview]; if (pbCell) // Restore, we may reuse it for a ComboBox. pbCell.arrowPosition = oldPosition; diff --git a/src/src.pro b/src/src.pro index 6658cbc9e0..c73d58819e 100644 --- a/src/src.pro +++ b/src/src.pro @@ -158,7 +158,7 @@ src_android.subdir = $$PWD/android } } SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_tracegen -qtConfig(regularexpression):pcre2 { +qtConfig(regularexpression):!qtConfig(system-pcre2):pcre2 { SUBDIRS += src_3rdparty_pcre2 src_corelib.depends += src_3rdparty_pcre2 } @@ -168,12 +168,18 @@ win32:SUBDIRS += src_winmain qtConfig(network) { SUBDIRS += src_network src_plugins.depends += src_network + qtHaveModule(gui):qtConfig(private_tests) { + src_network_doc_snippets.subdir = network/doc/snippets + src_network_doc_snippets.target = sub-network-doc-snippets + src_network_doc_snippets.depends = src_network + SUBDIRS += src_network_doc_snippets + } } qtConfig(sql) { SUBDIRS += src_sql src_plugins.depends += src_sql - contains(QT_CONFIG, private_tests) { + qtConfig(private_tests) { src_sql_doc_snippets.subdir = sql/doc/snippets src_sql_doc_snippets.target = sub-sql-doc-snippets src_sql_doc_snippets.depends = src_sql @@ -181,7 +187,16 @@ qtConfig(sql) { } } qtConfig(xml): SUBDIRS += src_xml -qtConfig(testlib): SUBDIRS += src_testlib +qtConfig(testlib) { + SUBDIRS += src_testlib + qtConfig(private_tests) { + src_testlib_doc_snippets.subdir = testlib/doc/snippets + src_testlib_doc_snippets.target = sub-testlib-doc-snippets + src_testlib_doc_snippets.depends = src_testlib + SUBDIRS += src_testlib_doc_snippets + } +} + qtConfig(dbus) { force_dbus_bootstrap|qtConfig(private_tests): \ SUBDIRS += src_tools_bootstrap_dbus @@ -240,6 +255,12 @@ qtConfig(gui) { SUBDIRS += src_opengl src_plugins.depends += src_opengl } + qtConfig(private_tests) { + src_widgets_doc_snippets.subdir = widgets/doc/snippets + src_widgets_doc_snippets.target = sub-widgets-doc-snippets + src_widgets_doc_snippets.depends = src_widgets + SUBDIRS += src_widgets_doc_snippets + } } } SUBDIRS += src_plugins diff --git a/src/testlib/doc/snippets/snippets.pro b/src/testlib/doc/snippets/snippets.pro index 28b6682b72..d1ca7ca3ec 100644 --- a/src/testlib/doc/snippets/snippets.pro +++ b/src/testlib/doc/snippets/snippets.pro @@ -1,3 +1,6 @@ +requires(qtHaveModule(sql)) +requires(qtHaveModule(widgets)) + TEMPLATE = app TARGET = testlib_cppsnippet QT = core testlib sql widgets diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index f45999c7fa..74507c11e1 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -2525,16 +2525,21 @@ bool QTest::compare_helper(bool success, const char *failureMsg, } template <typename T> -static bool floatingCompare(const T &t1, const T &t2) +static bool floatingCompare(const T &actual, const T &expected) { - switch (qFpClassify(t1)) + switch (qFpClassify(expected)) { case FP_INFINITE: - return (t1 < 0) == (t2 < 0) && qFpClassify(t2) == FP_INFINITE; + return (expected < 0) == (actual < 0) && qFpClassify(actual) == FP_INFINITE; case FP_NAN: - return qFpClassify(t2) == FP_NAN; + return qFpClassify(actual) == FP_NAN; default: - return qFuzzyCompare(t1, t2); + if (!qFuzzyIsNull(expected)) + return qFuzzyCompare(actual, expected); + Q_FALLTHROUGH(); + case FP_SUBNORMAL: // subnormal is always fuzzily null + case FP_ZERO: + return qFuzzyIsNull(actual); } } diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc index e4e1825bb5..72f8cdaf8c 100644 --- a/src/testlib/qtestcase.qdoc +++ b/src/testlib/qtestcase.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -109,19 +109,18 @@ continues. If not, a failure is recorded in the test log and the test function returns without attempting any later checks. - Always respect QCOMPARE() parameter semantics. The first parameter passed to it - should always be the actual value produced by the code-under-test, while the - second parameter should always be the expected value. When the values don't - match, QCOMPARE() prints them with the labels \e Actual and \e Expected. - If the parameter order is swapped, debugging a failing test can be confusing. + Always respect QCOMPARE() parameter semantics. The first parameter passed to + it should always be the actual value produced by the code-under-test, while + the second parameter should always be the expected value. When the values + don't match, QCOMPARE() prints them with the labels \e Actual and \e + Expected. If the parameter order is swapped, debugging a failing test can be + confusing and tests expecting zero may fail due to rounding errors. When comparing floating-point types (\c float, \c double, and \c qfloat16), - \l qFuzzyCompare() is used for finite values. Infinities match if they have + \l qFuzzyCompare() is used for finite values. If qFuzzyIsNull() is true for + both values, they are also considered equal. Infinities match if they have the same sign, and any NaN as actual value matches with any NaN as expected - value (even though NaN != NaN, even when they're identical). This means that - expecting 0 can fail when the actual value may be affected by rounding errors. - One solution to this is to offset both actual and expected values by adding - some suitable constant (such as 1). + value (even though NaN != NaN, even when they're identical). QCOMPARE() tries to output the contents of the values if the comparison fails, so it is visible from the test log why the comparison failed. diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index b406333fef..625bff5285 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1370,8 +1370,8 @@ QStringList qt_make_filter_list(const QString &filter) \snippet code/src_gui_dialogs_qfiledialog.cpp 6 - \note This is not supported on Android's native file dialog. Use - \l{setMimeTypeFilters()} instead. + \note With Android's native file dialog, the mime type matching the given + name filter is used because only mime types are supported. \sa setMimeTypeFilters(), setNameFilters() */ @@ -1444,9 +1444,6 @@ QStringList qt_strip_filters(const QStringList &filters) filters for each file type. For example, JPEG images have three possible extensions; if your application can open such files, selecting the \c image/jpeg mime type as a filter will allow you to open all of them. - - \note This is not supported on Android's native file dialog. Use - \l{setMimeTypeFilters()} instead. */ void QFileDialog::setNameFilters(const QStringList &filters) { diff --git a/src/widgets/doc/snippets/customviewstyle.cpp b/src/widgets/doc/snippets/customviewstyle.cpp index b9c10cb31d..1e4cf2b711 100644 --- a/src/widgets/doc/snippets/customviewstyle.cpp +++ b/src/widgets/doc/snippets/customviewstyle.cpp @@ -50,11 +50,10 @@ #include <QtWidgets> -#include "customviewstyle.h" +#include "./customstyle/customstyle.h" - - -void CustomViewStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const +void CustomStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const { //![0] diff --git a/src/widgets/doc/snippets/filedialogurls.cpp b/src/widgets/doc/snippets/filedialogurls.cpp index cd91e797e7..4b73a6c818 100644 --- a/src/widgets/doc/snippets/filedialogurls.cpp +++ b/src/widgets/doc/snippets/filedialogurls.cpp @@ -49,11 +49,10 @@ ****************************************************************************/ #include <QtGui> +#include <QFileDialog> -int main(int argv, char **args) +int loadFileDialog() { - QApplication app(argv, args); - //![0] QList<QUrl> urls; urls << QUrl::fromLocalFile("/Users/foo/Code/qt5") @@ -66,6 +65,5 @@ int main(int argv, char **args) // ... } //![0] - - return app.exec(); + return 1; } diff --git a/src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp b/src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp index 96e6bd650c..0ce135dc63 100644 --- a/src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp +++ b/src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp @@ -49,6 +49,9 @@ ****************************************************************************/ #include <QtGui> +#include <QGraphicsScene> +#include <QGraphicsEllipseItem> +#include <QStyleOptionGraphicsItem> class CustomScene : public QGraphicsScene { @@ -70,21 +73,9 @@ void CustomScene::drawItems(QPainter *painter, int numItems, for (int i = 0; i < numItems; ++i) { // Draw the item painter->save(); - painter->setMatrix(items[i]->sceneMatrix(), true); + painter->setTransform(items[i]->sceneTransform(), true); items[i]->paint(painter, &options[i], widget); painter->restore(); } } //! [0] - -int main(int argv, char **args) -{ - QApplication app(argv, args); - - CustomScene scene; - QGraphicsView view(&scene); - - view.show(); - - return app.exec(); -} diff --git a/src/widgets/doc/snippets/graphicsview.cpp b/src/widgets/doc/snippets/graphicsview.cpp index 9578f91eec..6262137c90 100644 --- a/src/widgets/doc/snippets/graphicsview.cpp +++ b/src/widgets/doc/snippets/graphicsview.cpp @@ -47,53 +47,70 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +#include <QGraphicsView> +#include <QOpenGLWidget> +#include <QPrinter> +#include <QPrintDialog> +#include <QStandardItem> +#include <QMimeData> +#include <QDrag> +#include <QGraphicsSceneMouseEvent> + +int main() +{ //! [0] QGraphicsScene scene; QGraphicsRectItem *rect = scene.addRect(QRectF(0, 0, 100, 100)); -QGraphicsItem *item = scene.itemAt(50, 50); -// item == rect +QGraphicsItem *item = scene.itemAt(50, 50, QTransform()); //! [0] +Q_UNUSED(rect); +Q_UNUSED(item); +} +void myPopulateScene(QGraphicsScene *) +{ + // Intentionally left empty +} +void snippetThatUsesMyPopulateScene() +{ //! [1] QGraphicsScene scene; myPopulateScene(&scene); - QGraphicsView view(&scene); view.show(); //! [1] +} - -//! [2] -class View : public QGraphicsView +class CustomItem : public QStandardItem { -Q_OBJECT - ... -public slots: - void zoomIn() { scale(1.2, 1.2); } - void zoomOut() { scale(1 / 1.2, 1 / 1.2); } - void rotateLeft() { rotate(-10); } - void rotateRight() { rotate(10); } - ... +public: + using QStandardItem::QStandardItem; + + int type() const override { return UserType; } + void mousePressEvent(QGraphicsSceneMouseEvent *event); + QStandardItem *clone() const override { return new CustomItem; } }; -//! [2] +void printScene() +{ //! [3] QGraphicsScene scene; +QPrinter printer; scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green)); -QPrinter printer; if (QPrintDialog(&printer).exec() == QDialog::Accepted) { QPainter painter(&printer); painter.setRenderHint(QPainter::Antialiasing); scene.render(&painter); } //! [3] +} - +void pixmapScene() +{ //! [4] QGraphicsScene scene; scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green)); @@ -106,21 +123,21 @@ painter.end(); pixmap.save("scene.png"); //! [4] - +} //! [5] void CustomItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { QMimeData *data = new QMimeData; - data->setColor(Qt::green); - QDrag *drag = new QDrag(event->widget()); drag->setMimeData(data); - drag->start(); + drag->exec(); } //! [5] - +void viewScene() +{ +QGraphicsScene scene; //! [6] QGraphicsView view(&scene); QOpenGLWidget *gl = new QOpenGLWidget(); @@ -129,3 +146,4 @@ format.setSamples(4); gl->setFormat(format); view.setViewport(gl); //! [6] +} diff --git a/src/widgets/doc/snippets/graphicsview_snippet.cpp b/src/widgets/doc/snippets/graphicsview_snippet.cpp new file mode 100644 index 0000000000..9d058d0f6a --- /dev/null +++ b/src/widgets/doc/snippets/graphicsview_snippet.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [2] +class View : public QGraphicsView +{ +Q_OBJECT + ... +public slots: + void zoomIn() { scale(1.2, 1.2); } + void zoomOut() { scale(1 / 1.2, 1 / 1.2); } + void rotateLeft() { rotate(-10); } + void rotateRight() { rotate(10); } + ... +}; +//! [2] diff --git a/src/widgets/doc/snippets/mdiareasnippets.cpp b/src/widgets/doc/snippets/mdiareasnippets.cpp index dec7aaa1e7..c1e2d37ccb 100644 --- a/src/widgets/doc/snippets/mdiareasnippets.cpp +++ b/src/widgets/doc/snippets/mdiareasnippets.cpp @@ -85,6 +85,7 @@ void addingSubWindowsExample() mdiArea.show(); } +/* int main(int argv, char **args) { QApplication app(argv, args); @@ -103,5 +104,5 @@ int main(int argv, char **args) return app.exec(); } - +*/ diff --git a/src/widgets/doc/snippets/myscrollarea.cpp b/src/widgets/doc/snippets/myscrollarea.cpp index dbf8da1603..8afe4a6834 100644 --- a/src/widgets/doc/snippets/myscrollarea.cpp +++ b/src/widgets/doc/snippets/myscrollarea.cpp @@ -48,7 +48,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> class MyScrollArea : public QAbstractScrollArea { @@ -97,8 +97,10 @@ void MyScrollArea::updateWidgetPosition() //! [0] } -void MyScrollArea::scrollContentsBy(int /*dx*/, int /*dy*/) +void MyScrollArea::scrollContentsBy(int dx, int dy) { + Q_UNUSED(dx); + Q_UNUSED(dy); updateWidgetPosition(); } @@ -118,21 +120,6 @@ void MyScrollArea::updateArea() void MyScrollArea::resizeEvent(QResizeEvent *event) { + Q_UNUSED(event); updateArea(); } - -int main(int argv, char **args) -{ - QApplication app(argv, args); - - QPixmap pixmap("mypixmap.png"); - QLabel label; - label.setPixmap(pixmap); - MyScrollArea area(&label); - area.resize(300, 300); - area.show(); - - area.setWidget(&label); - - return app.exec(); -} diff --git a/src/widgets/doc/snippets/snippets.pro b/src/widgets/doc/snippets/snippets.pro new file mode 100644 index 0000000000..f1d3596f9d --- /dev/null +++ b/src/widgets/doc/snippets/snippets.pro @@ -0,0 +1,16 @@ +requires(qtHaveModule(widgets)) +requires(qtHaveModule(printsupport)) + +TEMPLATE = app + +TARGET = widgets_snippets + +QT += widgets printsupport + +SOURCES += customviewstyle.cpp \ + filedialogurls.cpp \ + graphicssceneadditemsnippet.cpp \ + graphicsview.cpp \ + mdiareasnippets.cpp \ + myscrollarea.cpp + diff --git a/src/widgets/doc/src/graphicsview.qdoc b/src/widgets/doc/src/graphicsview.qdoc index 94c824c2ed..46a68adc56 100644 --- a/src/widgets/doc/src/graphicsview.qdoc +++ b/src/widgets/doc/src/graphicsview.qdoc @@ -327,7 +327,7 @@ Here is an example of how to implement zoom and rotate slots in a subclass of QGraphicsView: - \snippet graphicsview.cpp 2 + \snippet graphicsview_snippet.cpp 2 The slots could be connected to \l{QToolButton}{QToolButtons} with \l{QAbstractButton::autoRepeat}{autoRepeat} enabled. diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 865e3b2fb6..38fdbf2184 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -40,6 +40,7 @@ #include "qmenu.h" #include <QtWidgets/private/qtwidgetsglobal_p.h> +#include <QtWidgets/private/qwidgetwindow_p.h> #include "qdebug.h" #include "qstyle.h" @@ -2343,15 +2344,23 @@ void QMenuPrivate::popup(const QPoint &p, QAction *atAction, PositionFunction po // Use d->popupScreen to remember, because initialScreenIndex will be reset after the first showing. // However if eventLoop exists, then exec() already did this by calling createWinId(); so leave it alone. (QTBUG-76162) if (!eventLoop) { + bool screenSet = false; const int screenIndex = topData()->initialScreenIndex; if (screenIndex >= 0) popupScreen = screenIndex; if (auto s = QGuiApplication::screens().value(popupScreen)) { if (setScreen(s)) itemsDirty = true; - } else if (setScreenForPoint(p)) { - itemsDirty = true; + screenSet = true; + } else if (QMenu *parentMenu = qobject_cast<QMenu *>(parent)) { + // a submenu is always opened from an open parent menu, + // so show it on the same screen where the parent is. (QTBUG-76162) + if (setScreen(QMenuPrivate::get(parentMenu)->windowHandle()->screen())) + itemsDirty = true; + screenSet = true; } + if (!screenSet && setScreenForPoint(p)) + itemsDirty = true; } const bool contextMenu = isContextMenu(); diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index ed900f7805..2391945fd4 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -162,3 +162,4 @@ if (NOT CMAKE_VERSION VERSION_LESS 3.8) endif() expect_pass(test_import_plugins BINARY ${CMAKE_CTEST_COMMAND}) +expect_pass(test_versionless_targets) diff --git a/tests/auto/cmake/test_versionless_targets/CMakeLists.txt b/tests/auto/cmake/test_versionless_targets/CMakeLists.txt new file mode 100644 index 0000000000..d2edafbd3e --- /dev/null +++ b/tests/auto/cmake/test_versionless_targets/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.1) + +project(versionless_targets) + +set(QT_NO_CREATE_VERSIONLESS_TARGETS ON) + +find_package(Qt5Core REQUIRED) + +if (NOT TARGET Qt5::Core) + message(SEND_ERROR "Qt5::Core target not defined!") +endif() + +if (TARGET Qt::Core) + message(SEND_ERROR "Qt::Core target defined despite QT_NO_CREATE_VERSIONLESS_TARGETS!") +endif() + +set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF) + +find_package(Qt5Core REQUIRED) + +if (NOT TARGET Qt::Core) + message(SEND_ERROR "Qt::Core target not defined!") +endif() diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp index 513c811788..88dfdeccab 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp @@ -97,6 +97,13 @@ int main(int argc, char *argv[]) parser.process(app); const QString size = parser.value("size"); printf("Resizing %s to %s and saving to %s\n", qPrintable(parser.value("load")), qPrintable(size), qPrintable(parser.value("o"))); + } else if (command == "long") { + // A very long option (QTBUG-79926) + QCommandLineOption longOption(QStringList{QStringLiteral("looooooooooooong-option"), QStringLiteral("looooong-opt-alias")}); + longOption.setDescription(QStringLiteral("Short description")); + longOption.setValueName(QStringLiteral("looooooooooooong-value-name")); + parser.addOption(longOption); + parser.process(app); } else { // Call process again, to handle unknown options this time. parser.process(app); diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index 1e87c76d2f..493d8d4982 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -78,6 +78,7 @@ private slots: void testUnknownOption(); void testHelpAll_data(); void testHelpAll(); + void testVeryLongOptionNames(); }; static char *empty_argv[] = { 0 }; @@ -737,6 +738,38 @@ void tst_QCommandLineParser::testHelpAll() #endif // QT_CONFIG(process) } +void tst_QCommandLineParser::testVeryLongOptionNames() +{ +#if !QT_CONFIG(process) + QSKIP("This test requires QProcess support"); +#else +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) + 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" << "long" << "--help"); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QString output = process.readAll(); +#ifdef Q_OS_WIN + output.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); +#endif + const QStringList lines = output.split('\n'); + const int last = lines.count() - 1; + // Let's not compare everything, just the final parts. + QCOMPARE(lines.at(last - 7), " cdefghijklmnopqrstuvwxyz"); + QCOMPARE(lines.at(last - 6), " --looooooooooooong-option, --looooong-opt-alias <l Short description"); + QCOMPARE(lines.at(last - 5), " ooooooooooooong-value-name>"); + QCOMPARE(lines.at(last - 4), ""); + QCOMPARE(lines.at(last - 3), "Arguments:"); + QCOMPARE(lines.at(last - 2), " parsingMode The parsing mode to test."); + QCOMPARE(lines.at(last - 1), " command The command to execute."); + +#endif // QT_CONFIG(process) +} + QTEST_APPLESS_MAIN(tst_QCommandLineParser) #include "tst_qcommandlineparser.moc" diff --git a/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST b/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST index 5c81e74aa0..e646d71144 100644 --- a/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST +++ b/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST @@ -2,3 +2,4 @@ rhel-6.6 rhel-7.4 rhel-7.6 +sles diff --git a/tests/auto/testlib/selftests/expected_float.junitxml b/tests/auto/testlib/selftests/expected_float.junitxml index 602f9252a4..51a711efb7 100644 --- a/tests/auto/testlib/selftests/expected_float.junitxml +++ b/tests/auto/testlib/selftests/expected_float.junitxml @@ -17,8 +17,8 @@ Actual (operandLeft) : 999999999999 Expected (operandRight): 999999999998" result="fail"/> <failure tag="should FAIL 4" message="Compared doubles are not the same (fuzzy compare) - Actual (operandLeft) : 9.99999999999e-311 - Expected (operandRight): 9.99999999997e-311" result="fail"/> + Actual (operandLeft) : 1e-12 + Expected (operandRight): 9.99999999999e-13" result="fail"/> <failure tag="should FAIL 5" message="Compared doubles are not the same (fuzzy compare) Actual (operandLeft) : 9.99999999999e+306 Expected (operandRight): 9.99999999997e+306" result="fail"/> @@ -106,14 +106,14 @@ Actual (operandLeft) : 1 Expected (operandRight): 3" result="fail"/> <failure tag="should FAIL 2" message="Compared floats are not the same (fuzzy compare) - Actual (operandLeft) : 1e-07 - Expected (operandRight): 3e-07" result="fail"/> + Actual (operandLeft) : 1e-05 + Expected (operandRight): 3e-05" result="fail"/> <failure tag="should FAIL 3" message="Compared floats are not the same (fuzzy compare) Actual (operandLeft) : 99999 Expected (operandRight): 99998" result="fail"/> <failure tag="should FAIL 4" message="Compared floats are not the same (fuzzy compare) - Actual (operandLeft) : 9.9999e-40 - Expected (operandRight): 9.99971e-40" result="fail"/> + Actual (operandLeft) : 1.00001e-05 + Expected (operandRight): 9.9999e-06" result="fail"/> <failure tag="should FAIL 5" message="Compared floats are not the same (fuzzy compare) Actual (operandLeft) : 9.9999e+37 Expected (operandRight): 9.9997e+37" result="fail"/> @@ -201,14 +201,14 @@ Actual (operandLeft) : 1 Expected (operandRight): 3" result="fail"/> <failure tag="should FAIL 2" message="Compared qfloat16s are not the same (fuzzy compare) - Actual (operandLeft) : 0.0001 - Expected (operandRight): 0.0003" result="fail"/> + Actual (operandLeft) : 0.000999 + Expected (operandRight): 0.003" result="fail"/> <failure tag="should FAIL 3" message="Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 98 Expected (operandRight): 99" result="fail"/> <failure tag="should FAIL 4" message="Compared qfloat16s are not the same (fuzzy compare) - Actual (operandLeft) : 5.93e-05 - Expected (operandRight): 5.87e-05" result="fail"/> + Actual (operandLeft) : 0.00101 + Expected (operandRight): 0.00099" result="fail"/> <failure tag="should FAIL 5" message="Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 5.94e+04 Expected (operandRight): 5.88e+04" result="fail"/> @@ -295,9 +295,9 @@ <failure tag="1e0" message="Compared floats are not the same (fuzzy compare) Actual (t1): 1 Expected (t3): 3" result="fail"/> - <failure tag="1e-7" message="Compared floats are not the same (fuzzy compare) - Actual (t1): 1e-07 - Expected (t3): 3e-07" result="fail"/> + <failure tag="1e-5" message="Compared floats are not the same (fuzzy compare) + Actual (t1): 1e-05 + Expected (t3): 3e-05" result="fail"/> <failure tag="1e+7" message="Compared floats are not the same (fuzzy compare) Actual (t1): 1e+07 Expected (t3): 3e+07" result="fail"/> diff --git a/tests/auto/testlib/selftests/expected_float.lightxml b/tests/auto/testlib/selftests/expected_float.lightxml index 5f5114bb2e..cf82929fd0 100644 --- a/tests/auto/testlib/selftests/expected_float.lightxml +++ b/tests/auto/testlib/selftests/expected_float.lightxml @@ -38,8 +38,8 @@ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 4]]></DataTag> <Description><![CDATA[Compared doubles are not the same (fuzzy compare) - Actual (operandLeft) : 9.99999999999e-311 - Expected (operandRight): 9.99999999997e-311]]></Description> + Actual (operandLeft) : 1e-12 + Expected (operandRight): 9.99999999999e-13]]></Description> </Incident> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[should PASS 4]]></DataTag> @@ -230,8 +230,8 @@ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 2]]></DataTag> <Description><![CDATA[Compared floats are not the same (fuzzy compare) - Actual (operandLeft) : 1e-07 - Expected (operandRight): 3e-07]]></Description> + Actual (operandLeft) : 1e-05 + Expected (operandRight): 3e-05]]></Description> </Incident> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[should PASS 2]]></DataTag> @@ -248,8 +248,8 @@ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 4]]></DataTag> <Description><![CDATA[Compared floats are not the same (fuzzy compare) - Actual (operandLeft) : 9.9999e-40 - Expected (operandRight): 9.99971e-40]]></Description> + Actual (operandLeft) : 1.00001e-05 + Expected (operandRight): 9.9999e-06]]></Description> </Incident> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[should PASS 4]]></DataTag> @@ -440,8 +440,8 @@ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 2]]></DataTag> <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) - Actual (operandLeft) : 0.0001 - Expected (operandRight): 0.0003]]></Description> + Actual (operandLeft) : 0.000999 + Expected (operandRight): 0.003]]></Description> </Incident> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[should PASS 2]]></DataTag> @@ -458,8 +458,8 @@ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 4]]></DataTag> <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) - Actual (operandLeft) : 5.93e-05 - Expected (operandRight): 5.87e-05]]></Description> + Actual (operandLeft) : 0.00101 + Expected (operandRight): 0.00099]]></Description> </Incident> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[should PASS 4]]></DataTag> @@ -645,10 +645,10 @@ Expected (t3): 3]]></Description> </Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> - <DataTag><![CDATA[1e-7]]></DataTag> + <DataTag><![CDATA[1e-5]]></DataTag> <Description><![CDATA[Compared floats are not the same (fuzzy compare) - Actual (t1): 1e-07 - Expected (t3): 3e-07]]></Description> + Actual (t1): 1e-05 + Expected (t3): 3e-05]]></Description> </Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[1e+7]]></DataTag> diff --git a/tests/auto/testlib/selftests/expected_float.tap b/tests/auto/testlib/selftests/expected_float.tap index 9da51b93b3..f5249b8b4e 100644 --- a/tests/auto/testlib/selftests/expected_float.tap +++ b/tests/auto/testlib/selftests/expected_float.tap @@ -44,10 +44,10 @@ not ok 8 - doubleComparisons(should FAIL 4) --- type: QCOMPARE message: Compared doubles are not the same (fuzzy compare) - wanted: 9.99999999997e-311 (operandRight) - found: 9.99999999999e-311 (operandLeft) - expected: 9.99999999997e-311 (operandRight) - actual: 9.99999999999e-311 (operandLeft) + wanted: 9.99999999999e-13 (operandRight) + found: 1e-12 (operandLeft) + expected: 9.99999999999e-13 (operandRight) + actual: 1e-12 (operandLeft) at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp line: 103 @@ -388,22 +388,22 @@ not ok 40 - floatComparisons(should FAIL 1) found: 1 (operandLeft) expected: 3 (operandRight) actual: 1 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... ok 41 - floatComparisons(should PASS 1) not ok 42 - floatComparisons(should FAIL 2) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) - wanted: 3e-07 (operandRight) - found: 1e-07 (operandLeft) - expected: 3e-07 (operandRight) - actual: 1e-07 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + wanted: 3e-05 (operandRight) + found: 1e-05 (operandLeft) + expected: 3e-05 (operandRight) + actual: 1e-05 (operandLeft) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... ok 43 - floatComparisons(should PASS 2) not ok 44 - floatComparisons(should FAIL 3) @@ -414,22 +414,22 @@ not ok 44 - floatComparisons(should FAIL 3) found: 99999 (operandLeft) expected: 99998 (operandRight) actual: 99999 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... ok 45 - floatComparisons(should PASS 3) not ok 46 - floatComparisons(should FAIL 4) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) - wanted: 9.99971e-40 (operandRight) - found: 9.9999e-40 (operandLeft) - expected: 9.99971e-40 (operandRight) - actual: 9.9999e-40 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + wanted: 9.9999e-06 (operandRight) + found: 1.00001e-05 (operandLeft) + expected: 9.9999e-06 (operandRight) + actual: 1.00001e-05 (operandLeft) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... ok 47 - floatComparisons(should PASS 4) not ok 48 - floatComparisons(should FAIL 5) @@ -440,9 +440,9 @@ not ok 48 - floatComparisons(should FAIL 5) found: 9.9999e+37 (operandLeft) expected: 9.9997e+37 (operandRight) actual: 9.9999e+37 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... ok 49 - floatComparisons(should PASS: NaN == NaN) not ok 50 - floatComparisons(should FAIL: NaN != 0) @@ -453,9 +453,9 @@ not ok 50 - floatComparisons(should FAIL: NaN != 0) found: nan (operandLeft) expected: 0 (operandRight) actual: nan (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 51 - floatComparisons(should FAIL: 0 != NaN) --- @@ -465,9 +465,9 @@ not ok 51 - floatComparisons(should FAIL: 0 != NaN) found: 0 (operandLeft) expected: nan (operandRight) actual: 0 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 52 - floatComparisons(should FAIL: NaN != 1) --- @@ -477,9 +477,9 @@ not ok 52 - floatComparisons(should FAIL: NaN != 1) found: nan (operandLeft) expected: 1 (operandRight) actual: nan (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 53 - floatComparisons(should FAIL: 1 != NaN) --- @@ -489,9 +489,9 @@ not ok 53 - floatComparisons(should FAIL: 1 != NaN) found: 1 (operandLeft) expected: nan (operandRight) actual: 1 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... ok 54 - floatComparisons(should PASS: inf == inf) ok 55 - floatComparisons(should PASS: -inf == -inf) @@ -503,9 +503,9 @@ not ok 56 - floatComparisons(should FAIL: inf != -inf) found: inf (operandLeft) expected: -inf (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 57 - floatComparisons(should FAIL: -inf != inf) --- @@ -515,9 +515,9 @@ not ok 57 - floatComparisons(should FAIL: -inf != inf) found: -inf (operandLeft) expected: inf (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 58 - floatComparisons(should FAIL: inf != nan) --- @@ -527,9 +527,9 @@ not ok 58 - floatComparisons(should FAIL: inf != nan) found: inf (operandLeft) expected: nan (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 59 - floatComparisons(should FAIL: nan != inf) --- @@ -539,9 +539,9 @@ not ok 59 - floatComparisons(should FAIL: nan != inf) found: nan (operandLeft) expected: inf (operandRight) actual: nan (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 60 - floatComparisons(should FAIL: -inf != nan) --- @@ -551,9 +551,9 @@ not ok 60 - floatComparisons(should FAIL: -inf != nan) found: -inf (operandLeft) expected: nan (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 61 - floatComparisons(should FAIL: nan != -inf) --- @@ -563,9 +563,9 @@ not ok 61 - floatComparisons(should FAIL: nan != -inf) found: nan (operandLeft) expected: -inf (operandRight) actual: nan (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 62 - floatComparisons(should FAIL: inf != 0) --- @@ -575,9 +575,9 @@ not ok 62 - floatComparisons(should FAIL: inf != 0) found: inf (operandLeft) expected: 0 (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 63 - floatComparisons(should FAIL: 0 != inf) --- @@ -587,9 +587,9 @@ not ok 63 - floatComparisons(should FAIL: 0 != inf) found: 0 (operandLeft) expected: inf (operandRight) actual: 0 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 64 - floatComparisons(should FAIL: -inf != 0) --- @@ -599,9 +599,9 @@ not ok 64 - floatComparisons(should FAIL: -inf != 0) found: -inf (operandLeft) expected: 0 (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 65 - floatComparisons(should FAIL: 0 != -inf) --- @@ -611,9 +611,9 @@ not ok 65 - floatComparisons(should FAIL: 0 != -inf) found: 0 (operandLeft) expected: -inf (operandRight) actual: 0 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 66 - floatComparisons(should FAIL: inf != 1) --- @@ -623,9 +623,9 @@ not ok 66 - floatComparisons(should FAIL: inf != 1) found: inf (operandLeft) expected: 1 (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 67 - floatComparisons(should FAIL: 1 != inf) --- @@ -635,9 +635,9 @@ not ok 67 - floatComparisons(should FAIL: 1 != inf) found: 1 (operandLeft) expected: inf (operandRight) actual: 1 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 68 - floatComparisons(should FAIL: -inf != 1) --- @@ -647,9 +647,9 @@ not ok 68 - floatComparisons(should FAIL: -inf != 1) found: -inf (operandLeft) expected: 1 (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 69 - floatComparisons(should FAIL: 1 != -inf) --- @@ -659,9 +659,9 @@ not ok 69 - floatComparisons(should FAIL: 1 != -inf) found: 1 (operandLeft) expected: -inf (operandRight) actual: 1 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 70 - floatComparisons(should FAIL: inf != max) --- @@ -671,9 +671,9 @@ not ok 70 - floatComparisons(should FAIL: inf != max) found: inf (operandLeft) expected: 3.40282e+38 (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 71 - floatComparisons(should FAIL: inf != -max) --- @@ -683,9 +683,9 @@ not ok 71 - floatComparisons(should FAIL: inf != -max) found: inf (operandLeft) expected: -3.40282e+38 (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 72 - floatComparisons(should FAIL: max != inf) --- @@ -695,9 +695,9 @@ not ok 72 - floatComparisons(should FAIL: max != inf) found: 3.40282e+38 (operandLeft) expected: inf (operandRight) actual: 3.40282e+38 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 73 - floatComparisons(should FAIL: -max != inf) --- @@ -707,9 +707,9 @@ not ok 73 - floatComparisons(should FAIL: -max != inf) found: -3.40282e+38 (operandLeft) expected: inf (operandRight) actual: -3.40282e+38 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 74 - floatComparisons(should FAIL: -inf != max) --- @@ -719,9 +719,9 @@ not ok 74 - floatComparisons(should FAIL: -inf != max) found: -inf (operandLeft) expected: 3.40282e+38 (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 75 - floatComparisons(should FAIL: -inf != -max) --- @@ -731,9 +731,9 @@ not ok 75 - floatComparisons(should FAIL: -inf != -max) found: -inf (operandLeft) expected: -3.40282e+38 (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 76 - floatComparisons(should FAIL: max != -inf) --- @@ -743,9 +743,9 @@ not ok 76 - floatComparisons(should FAIL: max != -inf) found: 3.40282e+38 (operandLeft) expected: -inf (operandRight) actual: 3.40282e+38 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 77 - floatComparisons(should FAIL: -max != -inf) --- @@ -755,9 +755,9 @@ not ok 77 - floatComparisons(should FAIL: -max != -inf) found: -3.40282e+38 (operandLeft) expected: -inf (operandRight) actual: -3.40282e+38 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:139) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 137 + line: 139 ... not ok 78 - float16Comparisons(should FAIL 1) --- @@ -767,22 +767,22 @@ not ok 78 - float16Comparisons(should FAIL 1) found: 1 (operandLeft) expected: 3 (operandRight) actual: 1 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... ok 79 - float16Comparisons(should PASS 1) not ok 80 - float16Comparisons(should FAIL 2) --- type: QCOMPARE message: Compared qfloat16s are not the same (fuzzy compare) - wanted: 0.0003 (operandRight) - found: 0.0001 (operandLeft) - expected: 0.0003 (operandRight) - actual: 0.0001 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + wanted: 0.003 (operandRight) + found: 0.000999 (operandLeft) + expected: 0.003 (operandRight) + actual: 0.000999 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... ok 81 - float16Comparisons(should PASS 2) not ok 82 - float16Comparisons(should FAIL 3) @@ -793,22 +793,22 @@ not ok 82 - float16Comparisons(should FAIL 3) found: 98 (operandLeft) expected: 99 (operandRight) actual: 98 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... ok 83 - float16Comparisons(should PASS 3) not ok 84 - float16Comparisons(should FAIL 4) --- type: QCOMPARE message: Compared qfloat16s are not the same (fuzzy compare) - wanted: 5.87e-05 (operandRight) - found: 5.93e-05 (operandLeft) - expected: 5.87e-05 (operandRight) - actual: 5.93e-05 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + wanted: 0.00099 (operandRight) + found: 0.00101 (operandLeft) + expected: 0.00099 (operandRight) + actual: 0.00101 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... ok 85 - float16Comparisons(should PASS 4) not ok 86 - float16Comparisons(should FAIL 5) @@ -819,9 +819,9 @@ not ok 86 - float16Comparisons(should FAIL 5) found: 5.94e+04 (operandLeft) expected: 5.88e+04 (operandRight) actual: 5.94e+04 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... ok 87 - float16Comparisons(should PASS: NaN == NaN) not ok 88 - float16Comparisons(should FAIL: NaN != 0) @@ -832,9 +832,9 @@ not ok 88 - float16Comparisons(should FAIL: NaN != 0) found: nan (operandLeft) expected: 0 (operandRight) actual: nan (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 89 - float16Comparisons(should FAIL: 0 != NaN) --- @@ -844,9 +844,9 @@ not ok 89 - float16Comparisons(should FAIL: 0 != NaN) found: 0 (operandLeft) expected: nan (operandRight) actual: 0 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 90 - float16Comparisons(should FAIL: NaN != 1) --- @@ -856,9 +856,9 @@ not ok 90 - float16Comparisons(should FAIL: NaN != 1) found: nan (operandLeft) expected: 1 (operandRight) actual: nan (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 91 - float16Comparisons(should FAIL: 1 != NaN) --- @@ -868,9 +868,9 @@ not ok 91 - float16Comparisons(should FAIL: 1 != NaN) found: 1 (operandLeft) expected: nan (operandRight) actual: 1 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... ok 92 - float16Comparisons(should PASS: inf == inf) ok 93 - float16Comparisons(should PASS: -inf == -inf) @@ -882,9 +882,9 @@ not ok 94 - float16Comparisons(should FAIL: inf != -inf) found: inf (operandLeft) expected: -inf (operandRight) actual: inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 95 - float16Comparisons(should FAIL: -inf != inf) --- @@ -894,9 +894,9 @@ not ok 95 - float16Comparisons(should FAIL: -inf != inf) found: -inf (operandLeft) expected: inf (operandRight) actual: -inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 96 - float16Comparisons(should FAIL: inf != nan) --- @@ -906,9 +906,9 @@ not ok 96 - float16Comparisons(should FAIL: inf != nan) found: inf (operandLeft) expected: nan (operandRight) actual: inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 97 - float16Comparisons(should FAIL: nan != inf) --- @@ -918,9 +918,9 @@ not ok 97 - float16Comparisons(should FAIL: nan != inf) found: nan (operandLeft) expected: inf (operandRight) actual: nan (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 98 - float16Comparisons(should FAIL: -inf != nan) --- @@ -930,9 +930,9 @@ not ok 98 - float16Comparisons(should FAIL: -inf != nan) found: -inf (operandLeft) expected: nan (operandRight) actual: -inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 99 - float16Comparisons(should FAIL: nan != -inf) --- @@ -942,9 +942,9 @@ not ok 99 - float16Comparisons(should FAIL: nan != -inf) found: nan (operandLeft) expected: -inf (operandRight) actual: nan (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 100 - float16Comparisons(should FAIL: inf != 0) --- @@ -954,9 +954,9 @@ not ok 100 - float16Comparisons(should FAIL: inf != 0) found: inf (operandLeft) expected: 0 (operandRight) actual: inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 101 - float16Comparisons(should FAIL: 0 != inf) --- @@ -966,9 +966,9 @@ not ok 101 - float16Comparisons(should FAIL: 0 != inf) found: 0 (operandLeft) expected: inf (operandRight) actual: 0 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 102 - float16Comparisons(should FAIL: -inf != 0) --- @@ -978,9 +978,9 @@ not ok 102 - float16Comparisons(should FAIL: -inf != 0) found: -inf (operandLeft) expected: 0 (operandRight) actual: -inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 103 - float16Comparisons(should FAIL: 0 != -inf) --- @@ -990,9 +990,9 @@ not ok 103 - float16Comparisons(should FAIL: 0 != -inf) found: 0 (operandLeft) expected: -inf (operandRight) actual: 0 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 104 - float16Comparisons(should FAIL: inf != 1) --- @@ -1002,9 +1002,9 @@ not ok 104 - float16Comparisons(should FAIL: inf != 1) found: inf (operandLeft) expected: 1 (operandRight) actual: inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 105 - float16Comparisons(should FAIL: 1 != inf) --- @@ -1014,9 +1014,9 @@ not ok 105 - float16Comparisons(should FAIL: 1 != inf) found: 1 (operandLeft) expected: inf (operandRight) actual: 1 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 106 - float16Comparisons(should FAIL: -inf != 1) --- @@ -1026,9 +1026,9 @@ not ok 106 - float16Comparisons(should FAIL: -inf != 1) found: -inf (operandLeft) expected: 1 (operandRight) actual: -inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 107 - float16Comparisons(should FAIL: 1 != -inf) --- @@ -1038,9 +1038,9 @@ not ok 107 - float16Comparisons(should FAIL: 1 != -inf) found: 1 (operandLeft) expected: -inf (operandRight) actual: 1 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 108 - float16Comparisons(should FAIL: inf != max) --- @@ -1050,9 +1050,9 @@ not ok 108 - float16Comparisons(should FAIL: inf != max) found: inf (operandLeft) expected: 6.55e+04 (operandRight) actual: inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 109 - float16Comparisons(should FAIL: inf != -max) --- @@ -1062,9 +1062,9 @@ not ok 109 - float16Comparisons(should FAIL: inf != -max) found: inf (operandLeft) expected: -6.55e+04 (operandRight) actual: inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 110 - float16Comparisons(should FAIL: max != inf) --- @@ -1074,9 +1074,9 @@ not ok 110 - float16Comparisons(should FAIL: max != inf) found: 6.55e+04 (operandLeft) expected: inf (operandRight) actual: 6.55e+04 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 111 - float16Comparisons(should FAIL: -max != inf) --- @@ -1086,9 +1086,9 @@ not ok 111 - float16Comparisons(should FAIL: -max != inf) found: -6.55e+04 (operandLeft) expected: inf (operandRight) actual: -6.55e+04 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 112 - float16Comparisons(should FAIL: -inf != max) --- @@ -1098,9 +1098,9 @@ not ok 112 - float16Comparisons(should FAIL: -inf != max) found: -inf (operandLeft) expected: 6.55e+04 (operandRight) actual: -inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 113 - float16Comparisons(should FAIL: -inf != -max) --- @@ -1110,9 +1110,9 @@ not ok 113 - float16Comparisons(should FAIL: -inf != -max) found: -inf (operandLeft) expected: -6.55e+04 (operandRight) actual: -inf (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 114 - float16Comparisons(should FAIL: max != -inf) --- @@ -1122,9 +1122,9 @@ not ok 114 - float16Comparisons(should FAIL: max != -inf) found: 6.55e+04 (operandLeft) expected: -inf (operandRight) actual: 6.55e+04 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 115 - float16Comparisons(should FAIL: -max != -inf) --- @@ -1134,9 +1134,9 @@ not ok 115 - float16Comparisons(should FAIL: -max != -inf) found: -6.55e+04 (operandLeft) expected: -inf (operandRight) actual: -6.55e+04 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:174) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 171 + line: 174 ... not ok 116 - compareFloatTests(1e0) --- @@ -1146,21 +1146,21 @@ not ok 116 - compareFloatTests(1e0) found: 1 (t1) expected: 3 (t3) actual: 1 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:210) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:215) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 210 + line: 215 ... -not ok 117 - compareFloatTests(1e-7) +not ok 117 - compareFloatTests(1e-5) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) - wanted: 3e-07 (t3) - found: 1e-07 (t1) - expected: 3e-07 (t3) - actual: 1e-07 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:210) + wanted: 3e-05 (t3) + found: 1e-05 (t1) + expected: 3e-05 (t3) + actual: 1e-05 (t1) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:215) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 210 + line: 215 ... not ok 118 - compareFloatTests(1e+7) --- @@ -1170,9 +1170,9 @@ not ok 118 - compareFloatTests(1e+7) found: 1e+07 (t1) expected: 3e+07 (t3) actual: 1e+07 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:210) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:215) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 210 + line: 215 ... ok 119 - cleanupTestCase() 1..119 diff --git a/tests/auto/testlib/selftests/expected_float.teamcity b/tests/auto/testlib/selftests/expected_float.teamcity index af81296c42..f8d65a71c7 100644 --- a/tests/auto/testlib/selftests/expected_float.teamcity +++ b/tests/auto/testlib/selftests/expected_float.teamcity @@ -17,7 +17,7 @@ ##teamcity[testStarted name='doubleComparisons(should PASS 3)' flowId='tst_float'] ##teamcity[testFinished name='doubleComparisons(should PASS 3)' flowId='tst_float'] ##teamcity[testStarted name='doubleComparisons(should FAIL 4)' flowId='tst_float'] -##teamcity[testFailed name='doubleComparisons(should FAIL 4)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared doubles are not the same (fuzzy compare)|n Actual (operandLeft) : 9.99999999999e-311|n Expected (operandRight): 9.99999999997e-311' flowId='tst_float'] +##teamcity[testFailed name='doubleComparisons(should FAIL 4)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared doubles are not the same (fuzzy compare)|n Actual (operandLeft) : 1e-12|n Expected (operandRight): 9.99999999999e-13' flowId='tst_float'] ##teamcity[testFinished name='doubleComparisons(should FAIL 4)' flowId='tst_float'] ##teamcity[testStarted name='doubleComparisons(should PASS 4)' flowId='tst_float'] ##teamcity[testFinished name='doubleComparisons(should PASS 4)' flowId='tst_float'] @@ -114,7 +114,7 @@ ##teamcity[testStarted name='floatComparisons(should PASS 1)' flowId='tst_float'] ##teamcity[testFinished name='floatComparisons(should PASS 1)' flowId='tst_float'] ##teamcity[testStarted name='floatComparisons(should FAIL 2)' flowId='tst_float'] -##teamcity[testFailed name='floatComparisons(should FAIL 2)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (operandLeft) : 1e-07|n Expected (operandRight): 3e-07' flowId='tst_float'] +##teamcity[testFailed name='floatComparisons(should FAIL 2)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (operandLeft) : 1e-05|n Expected (operandRight): 3e-05' flowId='tst_float'] ##teamcity[testFinished name='floatComparisons(should FAIL 2)' flowId='tst_float'] ##teamcity[testStarted name='floatComparisons(should PASS 2)' flowId='tst_float'] ##teamcity[testFinished name='floatComparisons(should PASS 2)' flowId='tst_float'] @@ -124,7 +124,7 @@ ##teamcity[testStarted name='floatComparisons(should PASS 3)' flowId='tst_float'] ##teamcity[testFinished name='floatComparisons(should PASS 3)' flowId='tst_float'] ##teamcity[testStarted name='floatComparisons(should FAIL 4)' flowId='tst_float'] -##teamcity[testFailed name='floatComparisons(should FAIL 4)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (operandLeft) : 9.9999e-40|n Expected (operandRight): 9.99971e-40' flowId='tst_float'] +##teamcity[testFailed name='floatComparisons(should FAIL 4)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (operandLeft) : 1.00001e-05|n Expected (operandRight): 9.9999e-06' flowId='tst_float'] ##teamcity[testFinished name='floatComparisons(should FAIL 4)' flowId='tst_float'] ##teamcity[testStarted name='floatComparisons(should PASS 4)' flowId='tst_float'] ##teamcity[testFinished name='floatComparisons(should PASS 4)' flowId='tst_float'] @@ -221,7 +221,7 @@ ##teamcity[testStarted name='float16Comparisons(should PASS 1)' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should PASS 1)' flowId='tst_float'] ##teamcity[testStarted name='float16Comparisons(should FAIL 2)' flowId='tst_float'] -##teamcity[testFailed name='float16Comparisons(should FAIL 2)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0.0001|n Expected (operandRight): 0.0003' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL 2)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0.000999|n Expected (operandRight): 0.003' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should FAIL 2)' flowId='tst_float'] ##teamcity[testStarted name='float16Comparisons(should PASS 2)' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should PASS 2)' flowId='tst_float'] @@ -231,7 +231,7 @@ ##teamcity[testStarted name='float16Comparisons(should PASS 3)' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should PASS 3)' flowId='tst_float'] ##teamcity[testStarted name='float16Comparisons(should FAIL 4)' flowId='tst_float'] -##teamcity[testFailed name='float16Comparisons(should FAIL 4)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 5.93e-05|n Expected (operandRight): 5.87e-05' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL 4)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0.00101|n Expected (operandRight): 0.00099' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should FAIL 4)' flowId='tst_float'] ##teamcity[testStarted name='float16Comparisons(should PASS 4)' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should PASS 4)' flowId='tst_float'] @@ -325,9 +325,9 @@ ##teamcity[testStarted name='compareFloatTests(1e0)' flowId='tst_float'] ##teamcity[testFailed name='compareFloatTests(1e0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (t1): 1|n Expected (t3): 3' flowId='tst_float'] ##teamcity[testFinished name='compareFloatTests(1e0)' flowId='tst_float'] -##teamcity[testStarted name='compareFloatTests(1e-7)' flowId='tst_float'] -##teamcity[testFailed name='compareFloatTests(1e-7)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (t1): 1e-07|n Expected (t3): 3e-07' flowId='tst_float'] -##teamcity[testFinished name='compareFloatTests(1e-7)' flowId='tst_float'] +##teamcity[testStarted name='compareFloatTests(1e-5)' flowId='tst_float'] +##teamcity[testFailed name='compareFloatTests(1e-5)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (t1): 1e-05|n Expected (t3): 3e-05' flowId='tst_float'] +##teamcity[testFinished name='compareFloatTests(1e-5)' flowId='tst_float'] ##teamcity[testStarted name='compareFloatTests(1e+7)' flowId='tst_float'] ##teamcity[testFailed name='compareFloatTests(1e+7)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (t1): 1e+07|n Expected (t3): 3e+07' flowId='tst_float'] ##teamcity[testFinished name='compareFloatTests(1e+7)' flowId='tst_float'] diff --git a/tests/auto/testlib/selftests/expected_float.txt b/tests/auto/testlib/selftests/expected_float.txt index d22a52a63d..25c8c6b6de 100644 --- a/tests/auto/testlib/selftests/expected_float.txt +++ b/tests/auto/testlib/selftests/expected_float.txt @@ -17,8 +17,8 @@ FAIL! : tst_float::doubleComparisons(should FAIL 3) Compared doubles are not th Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::doubleComparisons(should PASS 3) FAIL! : tst_float::doubleComparisons(should FAIL 4) Compared doubles are not the same (fuzzy compare) - Actual (operandLeft) : 9.99999999999e-311 - Expected (operandRight): 9.99999999997e-311 + Actual (operandLeft) : 1e-12 + Expected (operandRight): 9.99999999999e-13 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::doubleComparisons(should PASS 4) FAIL! : tst_float::doubleComparisons(should FAIL 5) Compared doubles are not the same (fuzzy compare) @@ -138,8 +138,8 @@ FAIL! : tst_float::floatComparisons(should FAIL 1) Compared floats are not the Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::floatComparisons(should PASS 1) FAIL! : tst_float::floatComparisons(should FAIL 2) Compared floats are not the same (fuzzy compare) - Actual (operandLeft) : 1e-07 - Expected (operandRight): 3e-07 + Actual (operandLeft) : 1e-05 + Expected (operandRight): 3e-05 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::floatComparisons(should PASS 2) FAIL! : tst_float::floatComparisons(should FAIL 3) Compared floats are not the same (fuzzy compare) @@ -148,8 +148,8 @@ FAIL! : tst_float::floatComparisons(should FAIL 3) Compared floats are not the Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::floatComparisons(should PASS 3) FAIL! : tst_float::floatComparisons(should FAIL 4) Compared floats are not the same (fuzzy compare) - Actual (operandLeft) : 9.9999e-40 - Expected (operandRight): 9.99971e-40 + Actual (operandLeft) : 1.00001e-05 + Expected (operandRight): 9.9999e-06 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::floatComparisons(should PASS 4) FAIL! : tst_float::floatComparisons(should FAIL 5) Compared floats are not the same (fuzzy compare) @@ -269,8 +269,8 @@ FAIL! : tst_float::float16Comparisons(should FAIL 1) Compared qfloat16s are not Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::float16Comparisons(should PASS 1) FAIL! : tst_float::float16Comparisons(should FAIL 2) Compared qfloat16s are not the same (fuzzy compare) - Actual (operandLeft) : 0.0001 - Expected (operandRight): 0.0003 + Actual (operandLeft) : 0.000999 + Expected (operandRight): 0.003 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::float16Comparisons(should PASS 2) FAIL! : tst_float::float16Comparisons(should FAIL 3) Compared qfloat16s are not the same (fuzzy compare) @@ -279,8 +279,8 @@ FAIL! : tst_float::float16Comparisons(should FAIL 3) Compared qfloat16s are not Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::float16Comparisons(should PASS 3) FAIL! : tst_float::float16Comparisons(should FAIL 4) Compared qfloat16s are not the same (fuzzy compare) - Actual (operandLeft) : 5.93e-05 - Expected (operandRight): 5.87e-05 + Actual (operandLeft) : 0.00101 + Expected (operandRight): 0.00099 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::float16Comparisons(should PASS 4) FAIL! : tst_float::float16Comparisons(should FAIL 5) Compared qfloat16s are not the same (fuzzy compare) @@ -398,9 +398,9 @@ FAIL! : tst_float::compareFloatTests(1e0) Compared floats are not the same (fuz Actual (t1): 1 Expected (t3): 3 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] -FAIL! : tst_float::compareFloatTests(1e-7) Compared floats are not the same (fuzzy compare) - Actual (t1): 1e-07 - Expected (t3): 3e-07 +FAIL! : tst_float::compareFloatTests(1e-5) Compared floats are not the same (fuzzy compare) + Actual (t1): 1e-05 + Expected (t3): 3e-05 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] FAIL! : tst_float::compareFloatTests(1e+7) Compared floats are not the same (fuzzy compare) Actual (t1): 1e+07 diff --git a/tests/auto/testlib/selftests/expected_float.xml b/tests/auto/testlib/selftests/expected_float.xml index 247bce9577..8ddc72a917 100644 --- a/tests/auto/testlib/selftests/expected_float.xml +++ b/tests/auto/testlib/selftests/expected_float.xml @@ -40,8 +40,8 @@ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 4]]></DataTag> <Description><![CDATA[Compared doubles are not the same (fuzzy compare) - Actual (operandLeft) : 9.99999999999e-311 - Expected (operandRight): 9.99999999997e-311]]></Description> + Actual (operandLeft) : 1e-12 + Expected (operandRight): 9.99999999999e-13]]></Description> </Incident> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[should PASS 4]]></DataTag> @@ -232,8 +232,8 @@ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 2]]></DataTag> <Description><![CDATA[Compared floats are not the same (fuzzy compare) - Actual (operandLeft) : 1e-07 - Expected (operandRight): 3e-07]]></Description> + Actual (operandLeft) : 1e-05 + Expected (operandRight): 3e-05]]></Description> </Incident> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[should PASS 2]]></DataTag> @@ -250,8 +250,8 @@ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 4]]></DataTag> <Description><![CDATA[Compared floats are not the same (fuzzy compare) - Actual (operandLeft) : 9.9999e-40 - Expected (operandRight): 9.99971e-40]]></Description> + Actual (operandLeft) : 1.00001e-05 + Expected (operandRight): 9.9999e-06]]></Description> </Incident> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[should PASS 4]]></DataTag> @@ -442,8 +442,8 @@ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 2]]></DataTag> <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) - Actual (operandLeft) : 0.0001 - Expected (operandRight): 0.0003]]></Description> + Actual (operandLeft) : 0.000999 + Expected (operandRight): 0.003]]></Description> </Incident> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[should PASS 2]]></DataTag> @@ -460,8 +460,8 @@ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 4]]></DataTag> <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) - Actual (operandLeft) : 5.93e-05 - Expected (operandRight): 5.87e-05]]></Description> + Actual (operandLeft) : 0.00101 + Expected (operandRight): 0.00099]]></Description> </Incident> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[should PASS 4]]></DataTag> @@ -647,10 +647,10 @@ Expected (t3): 3]]></Description> </Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> - <DataTag><![CDATA[1e-7]]></DataTag> + <DataTag><![CDATA[1e-5]]></DataTag> <Description><![CDATA[Compared floats are not the same (fuzzy compare) - Actual (t1): 1e-07 - Expected (t3): 3e-07]]></Description> + Actual (t1): 1e-05 + Expected (t3): 3e-05]]></Description> </Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[1e+7]]></DataTag> diff --git a/tests/auto/testlib/selftests/float/float.pro b/tests/auto/testlib/selftests/float/float.pro index 479eb152c5..8f169921c3 100644 --- a/tests/auto/testlib/selftests/float/float.pro +++ b/tests/auto/testlib/selftests/float/float.pro @@ -1,9 +1,10 @@ -SOURCES += tst_float.cpp QT = core testlib - mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +INCLUDEPATH += ../../../../shared/ +HEADERS = ../../../../shared/emulationdetector.h +SOURCES += tst_float.cpp TARGET = float include($$QT_SOURCE_TREE/src/testlib/selfcover.pri) diff --git a/tests/auto/testlib/selftests/float/tst_float.cpp b/tests/auto/testlib/selftests/float/tst_float.cpp index cefd8a57c4..823495f863 100644 --- a/tests/auto/testlib/selftests/float/tst_float.cpp +++ b/tests/auto/testlib/selftests/float/tst_float.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -31,6 +31,8 @@ #include <QtTest/QtTest> #include <QDebug> +#include "emulationdetector.h" + // Test proper handling of floating-point types class tst_float: public QObject { @@ -113,16 +115,18 @@ void tst_float::doubleComparisons_data() const QTest::newRow("should PASS 1") << zero << zero; QTest::newRow("should FAIL 2") << 1.e-7 << 3.e-7; - // QCOMPARE for doubles uses qFuzzyCompare(), which succeeds if the numbers - // differ by no more than 1e-12 times the smaller value. Thus - // QCOMPARE(1e12-2, 1e12-1) should fail, while QCOMPARE(1e12+1, 1e12+2) - // should pass. + // QCOMPARE() uses qFuzzyCompare(), which succeeds if doubles differ by no + // more than 1e-12 times the smaller value; but QCOMPARE() also considers + // values equal if qFuzzyIsNull() is true for both, so all doubles smaller + // than 1e-12 are equal. Thus QCOMPARE(1e12-2, 1e12-1) should fail, while + // QCOMPARE(1e12+1, 1e12+2) should pass, as should QCOMPARE(1e-12-2e-24, + // 1e-12-1e-24), despite the values differing by more than one part in 1e12. QTest::newRow("should PASS 2") << 1e12 + one << 1e12 + 2.; QTest::newRow("should FAIL 3") << 1e12 - one << 1e12 - 2.; + QTest::newRow("should PASS 3") << 1e-12 << -1e-12; // ... but rounding makes that a bit unrelaible when scaled close to the bounds. - QTest::newRow("should PASS 3") << 1e-310 + 1e-322 << 1e-310 + 2e-322; - QTest::newRow("should FAIL 4") << 1e-310 - 1e-322 << 1e-310 - 3e-322; + QTest::newRow("should FAIL 4") << 1e-12 + 1e-24 << 1e-12 - 1e-24; QTest::newRow("should PASS 4") << 1e307 + 1e295 << 1e307 + 2e295; QTest::newRow("should FAIL 5") << 1e307 - 1e295 << 1e307 - 3e295; @@ -145,18 +149,20 @@ void tst_float::floatComparisons_data() const QTest::newRow("should FAIL 1") << one << 3.f; QTest::newRow("should PASS 1") << zero << zero; - QTest::newRow("should FAIL 2") << 1.e-7f << 3.e-7f; + QTest::newRow("should FAIL 2") << 1.e-5f << 3.e-5f; - // QCOMPARE for floats uses qFuzzyCompare(), which succeeds if the numbers - // differ by no more than 1e-5 times the smaller value. Thus - // QCOMPARE(1e5-2, 1e5-1) should fail, while QCOMPARE(1e5+1, 1e5+2) - // should pass. + // QCOMPARE() uses qFuzzyCompare(), which succeeds if the floats differ by + // no more than 1e-5 times the smaller value; but QCOMPARE() also considers + // values equal if qFuzzyIsNull is true for both, so all floats smaller than + // 1e-5 are equal. Thus QCOMPARE(1e5-2, 1e5-1) should fail, while + // QCOMPARE(1e5+1, 1e5+2) should pass, as should QCOMPARE(1e-5-2e-10, + // 1e-5-1e-10), despite the values differing by more than one part in 1e5. QTest::newRow("should PASS 2") << 1e5f + one << 1e5f + 2.f; QTest::newRow("should FAIL 3") << 1e5f - one << 1e5f - 2.f; + QTest::newRow("should PASS 3") << 1e-5f << -1e-5f; // ... but rounding makes that a bit unrelaible when scaled close to the bounds. - QTest::newRow("should PASS 3") << 1e-39f + 1e-44f << 1e-39f + 2e-44f; - QTest::newRow("should FAIL 4") << 1e-39f - 1e-44f << 1e-39f - 3e-44f; + QTest::newRow("should FAIL 4") << 1e-5f + 1e-10f << 1e-5f - 1e-10f; QTest::newRow("should PASS 4") << 1e38f + 1e33f << 1e38f + 2e33f; QTest::newRow("should FAIL 5") << 1e38f - 1e33f << 1e38f - 3e33f; @@ -175,18 +181,21 @@ void tst_float::float16Comparisons_data() const { QTest::addColumn<qfloat16>("operandLeft"); QTest::addColumn<qfloat16>("operandRight"); - qfloat16 zero(0), one(1); + const qfloat16 zero(0), one(1); + const qfloat16 tiny(EmulationDetector::isRunningArmOnX86() ? 0.00099f : 0.001f); QTest::newRow("should FAIL 1") << one << qfloat16(3); QTest::newRow("should PASS 1") << zero << zero; - QTest::newRow("should FAIL 2") << qfloat16(1e-4f) << qfloat16(3e-4f); + QTest::newRow("should FAIL 2") << qfloat16(1e-3f) << qfloat16(3e-3f); - // QCOMPARE for qfloat16s uses qFuzzyCompare() + // QCOMPARE for uses qFuzzyCompare(), which ignores differences of one part + // in 102.5 and considers any two qFuzzyIsNull() values, i.e. values smaller + // than 1e-3, equal QTest::newRow("should PASS 2") << qfloat16(1001) << qfloat16(1002); QTest::newRow("should FAIL 3") << qfloat16(98) << qfloat16(99); + QTest::newRow("should PASS 3") << tiny << -tiny; // ... which gets a bit unreliable near to the type's bounds - QTest::newRow("should PASS 3") << qfloat16(6e-5f) + qfloat16(6e-7f) << qfloat16(6e-5f) + qfloat16(11e-7f); - QTest::newRow("should FAIL 4") << qfloat16(6e-5f) - qfloat16(7e-7f) << qfloat16(6e-5f) - qfloat16(13e-7f); + QTest::newRow("should FAIL 4") << qfloat16(1.01e-3f) << qfloat16(0.99e-3f); QTest::newRow("should PASS 4") << qfloat16(6e4) + qfloat16(700) << qfloat16(6e4) + qfloat16(1200); QTest::newRow("should FAIL 5") << qfloat16(6e4) - qfloat16(600) << qfloat16(6e4) - qfloat16(1200); @@ -200,7 +209,7 @@ void tst_float::compareFloatTests() const // Create two more values // t2 differs from t1 by 1 ppm (part per million) // t3 differs from t1 by 200% - // we should consider that t1 == t2 and t1 != t3 + // We should consider that t1 == t2 and t1 != t3 (provided at least one is > 1e-5) const float t2 = t1 + (t1 / 1e6); const float t3 = 3 * t1; @@ -214,7 +223,7 @@ void tst_float::compareFloatTests_data() const { QTest::addColumn<float>("t1"); QTest::newRow("1e0") << 1e0f; - QTest::newRow("1e-7") << 1e-7f; + QTest::newRow("1e-5") << 1e-5f; QTest::newRow("1e+7") << 1e+7f; } diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index cab6589984..84090c22ca 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -940,6 +940,14 @@ bool tst_Selftests::compareLine(const QString &logger, const QString &subdir, return true; } + if (EmulationDetector::isRunningArmOnX86() && subdir == QLatin1String("float")) { + // QEMU cheats at qfloat16, so outputs it as if it were a float. + if (actualLine.endsWith(QLatin1String("Actual (operandLeft) : 0.001")) + && expectedLine.endsWith(QLatin1String("Actual (operandLeft) : 0.000999"))) { + return true; + } + } + *errorMessage = msgMismatch(actualLine, expectedLine); return false; } |