summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfile
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2010-10-13 18:00:00 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2010-10-19 08:34:35 (GMT)
commit9ea66f867c1aeb60dc4e90acefb2258a084740ca (patch)
tree7830fa8fb30db8b2068e1c6ff07d768cc8facbdc /tests/auto/qfile
parentc822fba71e2949eea3de49009ef99602a4110914 (diff)
downloadQt-9ea66f867c1aeb60dc4e90acefb2258a084740ca.zip
Qt-9ea66f867c1aeb60dc4e90acefb2258a084740ca.tar.gz
Qt-9ea66f867c1aeb60dc4e90acefb2258a084740ca.tar.bz2
Autotest for seeking beyond end of file and then writing
File engine refactor caused a regression in the TIFF image codec, as QFile::seek() previously worked like lseek() / fseek() in posix. But on symbian the native RFile::Seek api clamps to the end of the file if you attempt to seek beyond there. This test checks seek behaviour in the appropriate place, the QFile auto test. Reviewed-By: joao
Diffstat (limited to 'tests/auto/qfile')
-rw-r--r--tests/auto/qfile/tst_qfile.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 2524e6e..4e7cb9f 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -170,6 +170,7 @@ private slots:
void encodeName();
void truncate();
void seekToPos();
+ void seekAfterEndOfFile();
void FILEReadWrite();
void i18nFileName_data();
void i18nFileName();
@@ -1644,6 +1645,36 @@ void tst_QFile::seekToPos()
}
+void tst_QFile::seekAfterEndOfFile()
+{
+ QLatin1String filename("seekAfterEof.dat");
+ QFile::remove(filename);
+ {
+ QFile file(filename);
+ QVERIFY(file.open(QFile::WriteOnly));
+ file.write("abcd");
+ QCOMPARE(file.size(), qint64(4));
+ file.seek(8);
+ file.write("ijkl");
+ QCOMPARE(file.size(), qint64(12));
+ file.seek(4);
+ file.write("efgh");
+ QCOMPARE(file.size(), qint64(12));
+ file.seek(16);
+ file.write("----");
+ QCOMPARE(file.size(), qint64(20));
+ file.flush();
+ }
+
+ QFile file(filename);
+ QVERIFY(file.open(QFile::ReadOnly));
+ QByteArray contents = file.readAll();
+ QCOMPARE(contents.left(12), QByteArray("abcdefghijkl", 12));
+ //bytes 12-15 are uninitialised so we don't care what they read as.
+ QCOMPARE(contents.mid(16), QByteArray("----", 4));
+ file.close();
+ QFile::remove(filename);
+}
void tst_QFile::FILEReadWrite()
{