diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-05-09 05:36:04 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2011-05-09 08:42:28 (GMT) |
commit | 385107ebc71a74dae031b713ea5a9c54635eeff8 (patch) | |
tree | 7737f86a1d22df1aa4df3446e832a5f58418765e /tests | |
parent | 20512cdab97b530ee8ec767254e553d80164b3c6 (diff) | |
download | Qt-385107ebc71a74dae031b713ea5a9c54635eeff8.zip Qt-385107ebc71a74dae031b713ea5a9c54635eeff8.tar.gz Qt-385107ebc71a74dae031b713ea5a9c54635eeff8.tar.bz2 |
Remove Q_ASSERT's from qscriptvaluegenerated test
Report a fatal error if there are problems reading from the input data
stream rather than failing silently in non-debug builds.
Change-Id: I7a913bf47dccb37bab09e1cd79e5022b04e42c27
Task-number: QTBUG-17582
Reviewed-by: Rohan McGovern
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp index 4d20f89..df2d38a 100644 --- a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp +++ b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp @@ -545,6 +545,17 @@ static void squashTags(QString dataTag, const QVector<bool>& results, QList<QStr } } +static QString streamStatusString(QDataStream::Status s) +{ + switch (s) { + case QDataStream::ReadPastEnd: + return QString("ReadPastEnd"); + case QDataStream::ReadCorruptData: + return QString("ReadCorruptData"); + default: + return QString("Unknown (%1)").arg(static_cast<int>(s)); + } +} QHash<QString, QString> TestGenerator::generateTest() { @@ -596,7 +607,10 @@ QHash<QString, QString> TestGenerator::generateTest() m_tempFile.seek(0); QDataStream in(&m_tempFile); in >> dataTags; - Q_ASSERT(in.status() == in.Ok); + if (in.status() != in.Ok) + qFatal("%s: stream has bad status %s after reading dataTags", + Q_FUNC_INFO, + qPrintable(streamStatusString(in.status()))); while(!in.atEnd()) { @@ -720,10 +734,13 @@ QHash<QString, QString> TestGenerator::generateTest() castUInt32List.append(QPair<QString, quint32>(dataTag, castUInt32Res)); castUInt16List.append(QPair<QString, quint16>(dataTag, castUInt16Res)); - Q_ASSERT(in.status() == in.Ok); + if (in.status() != in.Ok) + qFatal("%s: stream has bad status %s after reading data items", + Q_FUNC_INFO, + qPrintable(streamStatusString(in.status()))); } - - Q_ASSERT(in.atEnd()); + if (!in.atEnd()) + qFatal("%s: stream has more data after reading all data items", Q_FUNC_INFO); // Generate. QHash<QString, QString> result; |