diff options
author | Martin Smith <msmith@trolltech.com> | 2010-01-05 12:27:33 (GMT) |
---|---|---|
committer | Martin Smith <msmith@trolltech.com> | 2010-01-05 12:27:33 (GMT) |
commit | 2f42f8eee39d03a84a24da8b1d047f8e58079a26 (patch) | |
tree | 1bce31e1052080511f53bd5c44a4e983135e22f1 /tests/auto/qfile | |
parent | 94c2fce09c34b629a6fcb5a9576c4646a1ac24a8 (diff) | |
parent | d03475b69aa552a490e32fb2b7ad4dfaeacecf93 (diff) | |
download | Qt-2f42f8eee39d03a84a24da8b1d047f8e58079a26.zip Qt-2f42f8eee39d03a84a24da8b1d047f8e58079a26.tar.gz Qt-2f42f8eee39d03a84a24da8b1d047f8e58079a26.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'tests/auto/qfile')
-rw-r--r-- | tests/auto/qfile/tst_qfile.cpp | 41 |
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) |