Fixed QTextStream "stdin" auto tests

On some platforms (like BlackBerry) qDebug doesn't write to stderr,
so we directly write to stderr with fprintf.

Change-Id: Ib86211c98cf4da1fa2dbea4600a78e2013dc1a5a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Bernd Weimer 2013-07-29 17:34:24 +02:00 committed by The Qt Project
parent cfb5dfb7e8
commit 983e921c54
3 changed files with 9 additions and 13 deletions

View File

@ -40,13 +40,11 @@
****************************************************************************/
#include <QtCore/QCoreApplication>
#include <QtCore/QTextStream>
#include <QtCore/QDebug>
#include <stdio.h>
int main(int argc, char **argv)
int main(int, char**)
{
QCoreApplication a(argc, argv);
qDebug() << QTextStream(stdin).readAll();
fprintf(stderr, "%s\n", QTextStream(stdin).readAll().toLatin1().constData());
return 0;
}

View File

@ -40,17 +40,16 @@
****************************************************************************/
#include <QtCore/QCoreApplication>
#include <QtCore/QTextStream>
#include <stdio.h>
int main(int argc, char **argv)
int main(int, char**)
{
QCoreApplication a(argc, argv);
QTextStream qin(stdin);
if (!qin.atEnd()) {
int a, b, c;
qin >> a >> b >> c;
qDebug("%d %d %d", a, b, c);
int a, b, c;
qin >> a >> b >> c;
fprintf(stderr, "%d %d %d\n", a, b, c);
}
return 0;
}

View File

@ -1425,8 +1425,7 @@ void tst_QTextStream::readAllFromStdin()
stdinProcess.closeWriteChannel();
QVERIFY(stdinProcess.waitForFinished(5000));
QChar quoteChar('"');
QCOMPARE(stream.readAll(), QString::fromLatin1("%1hello world%2 \n").arg(quoteChar).arg(quoteChar));
QCOMPARE(stream.readAll(), QString::fromLatin1("hello world\n"));
}
// ------------------------------------------------------------------------------