From 66dfbea290a8bdc38de2e7646e2b0f44e59bd21c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 30 Aug 2023 11:09:03 -0700 Subject: [PATCH] tst_QFileInfo: replace a portion of a macro with a lambda MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's very hard to debug a macro. Change-Id: I2b24e1d3cad44897906efffd17803b8eac9bd844 Reviewed-by: Ahmad Samir Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 9e8c93fac10b802448b6b7938054220984734434) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 2e70f3af9a3..4601c0391c3 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -2303,13 +2303,15 @@ void tst_QFileInfo::stdfilesystem() // We compare using absoluteFilePath since QFileInfo::operator== ends up using // canonicalFilePath which evaluates to empty-string for non-existent paths causing // these tests to always succeed. -#define COMPARE_CONSTRUCTION(filepath) \ - QCOMPARE(QFileInfo(fs::path(filepath)).absoluteFilePath(), \ - QFileInfo(QString::fromLocal8Bit(filepath)).absoluteFilePath()); \ - QCOMPARE(QFileInfo(base, fs::path(filepath)).absoluteFilePath(), \ - QFileInfo(base, QString::fromLocal8Bit(filepath)).absoluteFilePath()) - QDir base{ "../" }; // Used for the QFileInfo(QDir, ) ctor + auto doCompare = [&base](const char *filepath) { + QCOMPARE(QFileInfo(fs::path(filepath)).absoluteFilePath(), + QFileInfo(QString::fromLocal8Bit(filepath)).absoluteFilePath()); + QCOMPARE(QFileInfo(base, fs::path(filepath)).absoluteFilePath(), + QFileInfo(base, QString::fromLocal8Bit(filepath)).absoluteFilePath()); + }; +#define COMPARE_CONSTRUCTION(filepath) \ + doCompare(filepath); if (QTest::currentTestFailed()) return COMPARE_CONSTRUCTION("./file");