Restructure tst_QDir::mkdirRmdir_data()
Iterate over a struct array rather than having a list of strings to pull things out of, by individual index; this makes it easy to include the non-existence check for directories in the same loop. In the process, give the absolute-path tests a prefix to mirror the relative- prefix on their partners. This prepares the way for adding more test-cases. Change-Id: Id839caedf92387dfa9b94f31253410285f72ff70 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
10ec683a96
commit
c9ff943f8f
@ -349,21 +349,21 @@ void tst_QDir::mkdirRmdir_data()
|
|||||||
QTest::addColumn<QString>("path");
|
QTest::addColumn<QString>("path");
|
||||||
QTest::addColumn<bool>("recurse");
|
QTest::addColumn<bool>("recurse");
|
||||||
|
|
||||||
QStringList dirs;
|
const struct {
|
||||||
dirs << "testdir/one"
|
const char *name; // shall have a prefix added
|
||||||
<< "testdir/two/three/four"
|
const char *path; // relative
|
||||||
<< "testdir/../testdir/three";
|
bool recurse;
|
||||||
QTest::newRow("plain") << QDir::currentPath() + "/" + dirs.at(0) << false;
|
} cases[] = {
|
||||||
QTest::newRow("recursive") << QDir::currentPath() + "/" + dirs.at(1) << true;
|
{ "plain", "testdir/one", false },
|
||||||
QTest::newRow("with-..") << QDir::currentPath() + "/" + dirs.at(2) << false;
|
{ "recursive", "testdir/two/three/four", true },
|
||||||
|
{ "with-..", "testdir/../testdir/three", false },
|
||||||
|
};
|
||||||
|
|
||||||
QTest::newRow("relative-plain") << dirs.at(0) << false;
|
for (const auto &it : cases) {
|
||||||
QTest::newRow("relative-recursive") << dirs.at(1) << true;
|
QVERIFY(!QFile::exists(it.path));
|
||||||
QTest::newRow("relative-with-..") << dirs.at(2) << false;
|
QTest::addRow("absolute-%s", it.name) << (QDir::currentPath() + "/") + it.path << it.recurse;
|
||||||
|
QTest::addRow("relative-%s", it.name) << QString::fromLatin1(it.path) << it.recurse;
|
||||||
// Ensure that none of these directories already exist
|
}
|
||||||
for (int i = 0; i < dirs.count(); ++i)
|
|
||||||
QVERIFY(!QFile::exists(dirs.at(i)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDir::mkdirRmdir()
|
void tst_QDir::mkdirRmdir()
|
||||||
|
Loading…
Reference in New Issue
Block a user