summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2014-05-29 00:39:02 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-04 12:25:02 +0200
commit523440a15f83dfda30e6bede02f83d76d8765647 (patch)
treeeca5001030ae941c6c6c6ee95777fcb4567e5dc2 /tests
parent565ee701a0840998cd27589a62f9efd701ae863a (diff)
QSaveFile: error out in open when the file is a directory
Change-Id: Ifb1697fedf6dd28fe317282c8b4824f34ec61981 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
index 63b9266ff6..08b943ba72 100644
--- a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
+++ b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
@@ -94,6 +94,7 @@ private slots:
void transactionalWriteCanceled();
void transactionalWriteErrorRenaming();
void symlink();
+ void directory();
};
static inline QByteArray msgCannotOpen(const QFileDevice &f)
@@ -454,5 +455,29 @@ void tst_QSaveFile::symlink()
#endif
}
+void tst_QSaveFile::directory()
+{
+ QTemporaryDir dir;
+ QVERIFY(dir.isValid());
+
+ const QString subdir = dir.path() + QLatin1String("/subdir");
+ QVERIFY(QDir(dir.path()).mkdir(QStringLiteral("subdir")));
+ {
+ QFile sf(subdir);
+ QVERIFY(!sf.open(QIODevice::WriteOnly));
+ }
+
+#ifdef Q_OS_UNIX
+ //link to a directory
+ const QString linkToDir = dir.path() + QLatin1String("/linkToDir");
+ QVERIFY(QFile::link(subdir, linkToDir));
+
+ {
+ QFile sf(linkToDir);
+ QVERIFY(!sf.open(QIODevice::WriteOnly));
+ }
+#endif
+}
+
QTEST_MAIN(tst_QSaveFile)
#include "tst_qsavefile.moc"