summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEdward Welbourne <[email protected]>2025-06-12 15:56:12 +0200
committerEdward Welbourne <[email protected]>2025-06-30 21:40:41 +0200
commit0604e0f87e32314add37b657c54592be9290fac5 (patch)
tree9684ad008827aa1b028112e0ab7fba2b96ade7f5 /src
parentf4101d6a4c4e8279cea42729ce4fc7fb63af3ad7 (diff)
Add assertions to qtestlog.cpp where it branches on variant typeHEADdev
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')
-rw-r--r--src/testlib/qtestlog.cpp8
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);