summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtextstream/tst_qtextstream.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-03-15 17:44:28 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2011-03-15 17:44:35 (GMT)
commitad0f3996a9674def59766726db34191844d2af0a (patch)
treed029eeb8b988786a8859f98455e5bc3d9651cb80 /tests/auto/qtextstream/tst_qtextstream.cpp
parentc0cd8db0498daaa8151d1f80143b6849016bdc7c (diff)
parent5e47ee6a97f54f1cdac577f76cd338b40e624f32 (diff)
downloadQt-ad0f3996a9674def59766726db34191844d2af0a.zip
Qt-ad0f3996a9674def59766726db34191844d2af0a.tar.gz
Qt-ad0f3996a9674def59766726db34191844d2af0a.tar.bz2
Merge earth-team into master
Diffstat (limited to 'tests/auto/qtextstream/tst_qtextstream.cpp')
-rw-r--r--tests/auto/qtextstream/tst_qtextstream.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp
index 99f2556..2d7c24d 100644
--- a/tests/auto/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/qtextstream/tst_qtextstream.cpp
@@ -208,6 +208,7 @@ private slots:
void seek();
void pos();
void pos2();
+ void pos3LargeFile();
void readStdin();
void readAllFromStdin();
void readLineFromStdin();
@@ -1502,6 +1503,41 @@ void tst_QTextStream::pos2()
}
// ------------------------------------------------------------------------------
+void tst_QTextStream::pos3LargeFile()
+{
+ {
+ QFile file(TestFileName);
+ file.open(QIODevice::WriteOnly | QIODevice::Text);
+ QTextStream out( &file );
+ // NOTE: The unusual spacing is to ensure non-1-character whitespace.
+ QString lineString = " 0 1 2\t3 4\t \t5 6 7 8 9 \n";
+ // Approximate 50kb text file
+ const int NbLines = (50*1024) / lineString.length() + 1;
+ for (int line = 0; line < NbLines; ++line)
+ out << lineString;
+ // File is automatically flushed and closed on destruction.
+ }
+ QFile file(TestFileName);
+ file.open(QIODevice::ReadOnly | QIODevice::Text);
+ QTextStream in( &file );
+ const int testValues[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ int value;
+ while (true) {
+ in.pos();
+ for ( int i = 0; i < 10; ++i ) {
+ in >> value;
+ if (in.status() != QTextStream::Ok) {
+ // End case, i == 0 && eof reached.
+ QCOMPARE(i, 0);
+ QCOMPARE(in.status(), QTextStream::ReadPastEnd);
+ return;
+ }
+ QCOMPARE(value, testValues[i]);
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
void tst_QTextStream::readStdin()
{
#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)