diff options
author | Edward Welbourne <[email protected]> | 2025-06-12 15:56:12 +0200 |
---|---|---|
committer | Edward Welbourne <[email protected]> | 2025-06-30 21:40:41 +0200 |
commit | 0604e0f87e32314add37b657c54592be9290fac5 (patch) | |
tree | 9684ad008827aa1b028112e0ab7fba2b96ade7f5 /src/testlib/qtestlog.cpp | |
parent | f4101d6a4c4e8279cea42729ce4fc7fb63af3ad7 (diff) |
For ignored messages, only string and regex are possible. For messages
to warn about, a null variant is also possible.
Pick-to: 6.10 6.9
Change-Id: I3a1b0ebaf541fb8e26794409feb4c5ef9b61d3c3
Reviewed-by: Thiago Macieira <[email protected]>
Diffstat (limited to 'src/testlib/qtestlog.cpp')
-rw-r--r-- | src/testlib/qtestlog.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 8a94aa0e19f..f41242f357d 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -193,6 +193,7 @@ namespace QTest { if (const auto *regex = get_if<QRegularExpression>(&pattern)) return regex->match(message).hasMatch(); #endif + Q_ASSERT(pattern.metaType() == QMetaType::fromType<QString>()); return stringsMatch(pattern.toString(), message); } @@ -265,6 +266,9 @@ namespace QTest { if (!message.contains(*regex)) continue; #endif + } else { + // The no-arg clearFailOnWarnings()'s null pattern matches all messages. + Q_ASSERT(pattern.isNull()); } const size_t maxMsgLen = 1024; @@ -402,6 +406,10 @@ void QTestLog::printUnhandledIgnoreMessages() } else if (const auto *regex = get_if<QRegularExpression>(&list->pattern)) { message = "Did not receive any message matching: \"%1\""_L1.arg(regex->pattern()); #endif + } else { + Q_UNREACHABLE(); + message = "Missing message of unrecognized pattern type: \"%1\""_L1.arg( + list->pattern.metaType().name()); } for (auto &logger : QTest::loggers->allLoggers()) logger->addMessage(QAbstractTestLogger::Info, message); |