Skip to content

Commit

Permalink
QDirListing: extend unit tests
Browse files Browse the repository at this point in the history
Add the tests for the (move-)constructors and move-assignment.

Pick-to: 6.8
Change-Id: I795a314a0e6d1795006fe152397eb6d9eeb3c712
Reviewed-by: Ahmad Samir <[email protected]>
Reviewed-by: Marc Mutz <[email protected]>
  • Loading branch information
isolovev committed Aug 29, 2024
1 parent 71167b7 commit b646627
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/auto/corelib/io/qdirlisting/tst_qdirlisting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class tst_QDirListing : public QObject

private slots:
void initTestCase();
void constructorsAndAssignment();
void iterateRelativeDirectory_data();
void iterateRelativeDirectory();
void iterateResource_data();
Expand Down Expand Up @@ -182,6 +183,41 @@ void tst_QDirListing::initTestCase()
#endif
}

void tst_QDirListing::constructorsAndAssignment()
{
using F = QDirListing::IteratorFlag;
const QString path = "entrylist"_L1;
const auto flags = QDirListing::IteratorFlags{F::IncludeDotAndDotDot | F::IncludeHidden};
const QStringList nameFilters = {"*.cpp"_L1, "*.h"_L1};
{
const QDirListing dl{path, flags};
QCOMPARE_EQ(dl.iteratorPath(), path);
QCOMPARE_EQ(dl.iteratorFlags(), flags);
QVERIFY(dl.nameFilters().isEmpty());
}
{
const QDirListing dl{path, nameFilters, flags};
QCOMPARE_EQ(dl.iteratorPath(), path);
QCOMPARE_EQ(dl.iteratorFlags(), flags);
QCOMPARE_EQ(dl.nameFilters(), nameFilters);
}
{
QDirListing other{path, nameFilters, flags};
QDirListing dl{std::move(other)};
QCOMPARE_EQ(dl.iteratorPath(), path);
QCOMPARE_EQ(dl.iteratorFlags(), flags);
QCOMPARE_EQ(dl.nameFilters(), nameFilters);
}
{
QDirListing dl{"foo"_L1};
QDirListing other{path, nameFilters, flags};
dl = std::move(other);
QCOMPARE_EQ(dl.iteratorPath(), path);
QCOMPARE_EQ(dl.iteratorFlags(), flags);
QCOMPARE_EQ(dl.nameFilters(), nameFilters);
}
}

void tst_QDirListing::iterateRelativeDirectory_data()
{
QTest::addColumn<QString>("dirName"); // relative from current path or abs
Expand Down

0 comments on commit b646627

Please sign in to comment.