summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfile/tst_qfile.cpp
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-01-04 16:16:07 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-01-05 12:14:06 (GMT)
commitd03475b69aa552a490e32fb2b7ad4dfaeacecf93 (patch)
treeaa28da661b7cafb23f898180e2d699dbdba7712d /tests/auto/qfile/tst_qfile.cpp
parent190f45bcc7383bdc68a904e7dd5780372d00afba (diff)
downloadQt-d03475b69aa552a490e32fb2b7ad4dfaeacecf93.zip
Qt-d03475b69aa552a490e32fb2b7ad4dfaeacecf93.tar.gz
Qt-d03475b69aa552a490e32fb2b7ad4dfaeacecf93.tar.bz2
Small optimization in QIODevice::readAll()
.. and more testcases Reviewed-by: joao
Diffstat (limited to 'tests/auto/qfile/tst_qfile.cpp')
-rw-r--r--tests/auto/qfile/tst_qfile.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 2b2f431..e88c222 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -129,6 +129,8 @@ private slots:
void readLine();
void readLine2();
void readLineNullInLine();
+ void readAll_data();
+ void readAll();
void readAllStdin();
void readLineStdin();
void readLineStdin_lineByLine();
@@ -752,6 +754,45 @@ void tst_QFile::readLineNullInLine()
QCOMPARE(file.readLine(), QByteArray());
}
+void tst_QFile::readAll_data()
+{
+ QTest::addColumn<bool>("textMode");
+ QTest::addColumn<QString>("fileName");
+ QTest::newRow( "TextMode unixfile" ) << true << SRCDIR "testfile.txt";
+ QTest::newRow( "BinaryMode unixfile" ) << false << SRCDIR "testfile.txt";
+ QTest::newRow( "TextMode dosfile" ) << true << SRCDIR "dosfile.txt";
+ QTest::newRow( "BinaryMode dosfile" ) << false << SRCDIR "dosfile.txt";
+ QTest::newRow( "TextMode bigfile" ) << true << SRCDIR "tst_qfile.cpp";
+ QTest::newRow( "BinaryMode bigfile" ) << false << SRCDIR "tst_qfile.cpp";
+ QVERIFY(QFile(SRCDIR "tst_qfile.cpp").size() > 64*1024);
+}
+
+void tst_QFile::readAll()
+{
+ QFETCH( bool, textMode );
+ QFETCH( QString, fileName );
+
+ QFile file(fileName);
+ if (textMode)
+ QVERIFY(file.open(QFile::Text | QFile::ReadOnly));
+ else
+ QVERIFY(file.open(QFile::ReadOnly));
+
+ QByteArray a = file.readAll();
+ file.reset();
+ QVERIFY(file.pos() == 0);
+
+ QVERIFY(file.bytesAvailable() > 7);
+ QByteArray b = file.read(1);
+ char x;
+ file.getChar(&x);
+ b.append(x);
+ b.append(file.read(5));
+ b.append(file.readAll());
+
+ QCOMPARE(a, b);
+}
+
void tst_QFile::readAllStdin()
{
#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)