tst_QFileInfo: replace a portion of a macro with a lambda
It's very hard to debug a macro. Change-Id: I2b24e1d3cad44897906efffd17803b8eac9bd844 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 9e8c93fac10b802448b6b7938054220984734434) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
641459e986
commit
66dfbea290
@ -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, <path>) 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");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user