summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-11-16 16:38:18 (GMT)
committerJoão Abecasis <joao@abecasis.name>2009-11-17 13:06:40 (GMT)
commit1e6b424b692b20dcfec920f8d3563e520ec1ff05 (patch)
treee6def3b0d0882462bd3334f2f9ecd254b0c1a567 /tests
parent0626fc90d79d114402a7cf8727c63d489f13d8cb (diff)
downloadQt-1e6b424b692b20dcfec920f8d3563e520ec1ff05.zip
Qt-1e6b424b692b20dcfec920f8d3563e520ec1ff05.tar.gz
Qt-1e6b424b692b20dcfec920f8d3563e520ec1ff05.tar.bz2
Removing unnecessary chunking and stat'ing when reading QIODevice
Chunk size increased to QIODEVICE_BUFFERSIZE (currently 16k) where chunking is still needed. Namely, on sequential devices and when QByteArray is unable to allocate a large enough buffer. This is necessary for backward compatibility Improved validation and prevention of overflow in maxSize argument. Updated autotest that relied on a null QByteArray when no data was available and no errors were found. The only guarantee we should be providing in this case is an empty result -- even though that behavior is preserved for the time being. Affected functions: * QIODevice::read(qint64 maxSize) Chunking will still happen for large maxSize (i.e., QByteArray resize fails), where it could be used as a synonym for QIODevice::readAll(). No stat'ing performed. Read from device continues for as long as it is successful. Stops if an error occurs or if we get less data than requested. * QIODevice::readAll() Chunking is performed for sequential devices where total size wouldn't be known beforehand. For sequential devices, reading continues as long as data is returned, even if less than requested. Non-sequential devices will be stat'ed once. If QIODevice::size returns 0, this is taken to mean unknown size and chunking is performed. Otherwise, a single read request is made for the specified size. On failure to resize QByteArray, nothing is returned. * QIODevice::readLine(qint64 maxSize) Chunking is performed for maxSize == 0, or if we can't allocate a large enough buffer. No stat'ing performed at this level. Read from device continues until EOL is found, as long as we get all requested data. Task-number: QT-2347 Reviewed-by: Thiago Macieira Reviewed-by: Miikka Heikkinen
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qfile/tst_qfile.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index e4e63ff..cf46ce1 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -2491,13 +2491,13 @@ void tst_QFile::readEof()
}
QByteArray ret = file.read(10);
- QVERIFY(ret.isNull());
+ QVERIFY(ret.isEmpty());
QVERIFY(file.error() == QFile::NoError);
QVERIFY(file.atEnd());
// Do it again to ensure that we get the same result
ret = file.read(10);
- QVERIFY(ret.isNull());
+ QVERIFY(ret.isEmpty());
QVERIFY(file.error() == QFile::NoError);
QVERIFY(file.atEnd());
}