Simplify tst_Selftests::compareLine by handling the trivial case first
If the two lines have identical texts, the comparison returns true. So don't complicate various other conditions on the way there with filtering out that case; deal with it first so they don't need to. Change-Id: Iebd230704ce5f53d12d5afa64aab30f83bb9d407 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>bb10
parent
779a73762d
commit
30101884a6
|
|
@ -893,16 +893,19 @@ bool tst_Selftests::compareLine(const QString &logger, const QString &subdir,
|
|||
const QString &actualLine, const QString &expectedLine,
|
||||
QString *errorMessage) const
|
||||
{
|
||||
if (subdir == QLatin1String("assert") && actualLine.contains(QLatin1String("ASSERT: "))
|
||||
&& expectedLine.contains(QLatin1String("ASSERT: ")) && actualLine != expectedLine) {
|
||||
if (actualLine == expectedLine)
|
||||
return true;
|
||||
|
||||
if (subdir == QLatin1String("assert")
|
||||
&& actualLine.contains(QLatin1String("ASSERT: "))
|
||||
&& expectedLine.contains(QLatin1String("ASSERT: "))) {
|
||||
// Q_ASSERT uses __FILE__, the exact contents of which are
|
||||
// undefined. If have we something that looks like a Q_ASSERT and we
|
||||
// were expecting to see a Q_ASSERT, we'll skip the line.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (expectedLine.startsWith(QLatin1String("FAIL! : tst_Exception::throwException() Caught unhandled exce"))
|
||||
&& actualLine != expectedLine) {
|
||||
if (expectedLine.startsWith(QLatin1String("FAIL! : tst_Exception::throwException() Caught unhandled exce"))) {
|
||||
// On some platforms we compile without RTTI, and as a result we never throw an exception
|
||||
if (actualLine.simplified() != QLatin1String("tst_Exception::throwException()")) {
|
||||
*errorMessage = QString::fromLatin1("'%1' != 'tst_Exception::throwException()'").arg(actualLine);
|
||||
|
|
@ -941,9 +944,6 @@ bool tst_Selftests::compareLine(const QString &logger, const QString &subdir,
|
|||
if (actualLine.startsWith(QLatin1String("Totals:")) && expectedLine.startsWith(QLatin1String("Totals:")))
|
||||
return true;
|
||||
|
||||
if (actualLine == expectedLine)
|
||||
return true;
|
||||
|
||||
*errorMessage = msgMismatch(actualLine, expectedLine);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue