summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-05-09 15:36:04 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2011-05-18 11:02:59 +1000
commitb27401354b5bfdbd8830a88efdb470ec87156ec2 (patch)
tree68dec54d3be53292e5bbc6c78413783a1831f217
parent49e993f59b7850de0f4e04c5cf858bd50d5d8ba9 (diff)
downloadqtscript-b27401354b5bfdbd8830a88efdb470ec87156ec2.tar.gz
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 (cherry picked from commit 385107ebc71a74dae031b713ea5a9c54635eeff8)
-rw-r--r--tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp25
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;