summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-04-12 04:53:36 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2011-04-12 05:38:20 (GMT)
commit3475168550c1a804f04f2a4edfeb30c04cd36551 (patch)
treeec1587bdc87e6f554c31e09cb1a3a2e26f16b181
parent78722d6b6e9ba0f6de1a4eba232aad2f96a339f2 (diff)
downloadQt-3475168550c1a804f04f2a4edfeb30c04cd36551.zip
Qt-3475168550c1a804f04f2a4edfeb30c04cd36551.tar.gz
Qt-3475168550c1a804f04f2a4edfeb30c04cd36551.tar.bz2
Reduce usage of Q_ASSERT in autotests.
Using Q_ASSERT does nothing in release-mode builds, and in debug builds it causes tests to terminate prematurely. It is much better to use QVERIFY or QCOMPARE. Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern
-rw-r--r--tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp40
-rw-r--r--tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp10
-rw-r--r--tests/auto/modeltest/modeltest.cpp139
-rw-r--r--tests/auto/q3listview/tst_q3listview.cpp2
-rw-r--r--tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp10
-rw-r--r--tests/auto/qbuffer/tst_qbuffer.cpp3
-rw-r--r--tests/auto/qchar/tst_qchar.cpp4
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp2
-rw-r--r--tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp2
-rw-r--r--tests/auto/qdbusthreading/tst_qdbusthreading.cpp2
-rw-r--r--tests/auto/qdirmodel/tst_qdirmodel.cpp6
-rw-r--r--tests/auto/qfiledialog2/tst_qfiledialog2.cpp2
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp2
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp2
-rw-r--r--tests/auto/qinputdialog/tst_qinputdialog.cpp18
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp4
-rw-r--r--tests/auto/qmessagebox/tst_qmessagebox.cpp49
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp4
-rw-r--r--tests/auto/qprocess/tst_qprocess.cpp2
-rw-r--r--tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp4
-rw-r--r--tests/auto/qsharedpointer/tst_qsharedpointer.cpp22
-rw-r--r--tests/auto/qsplitter/tst_qsplitter.cpp6
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp4
-rw-r--r--tests/auto/qstring/tst_qstring.cpp30
-rw-r--r--tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp18
-rw-r--r--tests/auto/qtextcodec/tst_qtextcodec.cpp8
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp3
-rw-r--r--tests/auto/xmlpatternsxqts/tst_suitetest.cpp2
30 files changed, 197 insertions, 207 deletions
diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
index 6bcb4eb..7237553 100644
--- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
+++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
@@ -81,7 +81,7 @@ private:
void recursiveCompareObjects(const QDeclarativeDebugObjectReference &a, const QDeclarativeDebugObjectReference &b) const;
void recursiveCompareContexts(const QDeclarativeDebugContextReference &a, const QDeclarativeDebugContextReference &b) const;
void compareProperties(const QDeclarativeDebugPropertyReference &a, const QDeclarativeDebugPropertyReference &b) const;
-
+
QDeclarativeDebugConnection *m_conn;
QDeclarativeEngineDebug *m_dbg;
QDeclarativeEngine *m_engine;
@@ -123,7 +123,7 @@ QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject(int conte
{
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
-
+
if (q_engines->engines().count() == 0)
return QDeclarativeDebugObjectReference();
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
@@ -353,7 +353,7 @@ void tst_QDeclarativeDebug::initTestCase()
for (int i=0; i<qml.count(); i++) {
QDeclarativeComponent component(m_engine);
component.setData(qml[i], QUrl::fromLocalFile(""));
- Q_ASSERT(component.isReady()); // fails if bad syntax
+ QVERIFY(component.isReady()); // fails if bad syntax
m_components << qobject_cast<QDeclarativeItem*>(component.create());
}
m_rootItem = qobject_cast<QDeclarativeItem*>(m_components.first());
@@ -367,7 +367,7 @@ void tst_QDeclarativeDebug::initTestCase()
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
- Q_ASSERT(ok);
+ QVERIFY(ok);
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
m_dbg = new QDeclarativeEngineDebug(m_conn, this);
QTRY_VERIFY(m_dbg->status() == QDeclarativeEngineDebug::Enabled);
@@ -424,7 +424,7 @@ void tst_QDeclarativeDebug::watch_property()
QDeclarativeDebugPropertyReference prop = findProperty(obj.properties(), "width");
QDeclarativeDebugPropertyWatch *watch;
-
+
QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
watch = unconnected->addWatch(prop, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
@@ -435,7 +435,7 @@ void tst_QDeclarativeDebug::watch_property()
QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
delete watch;
-
+
watch = m_dbg->addWatch(prop, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
QCOMPARE(watch->objectDebugId(), obj.debugId());
@@ -467,12 +467,12 @@ void tst_QDeclarativeDebug::watch_object()
{
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
-
- Q_ASSERT(q_engines->engines().count() > 0);
+
+ QVERIFY(q_engines->engines().count() > 0);
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
waitForQuery(q_context);
- Q_ASSERT(q_context->rootContext().objects().count() > 0);
+ QVERIFY(q_context->rootContext().objects().count() > 0);
QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
waitForQuery(q_obj);
@@ -489,7 +489,7 @@ void tst_QDeclarativeDebug::watch_object()
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
delete watch;
delete unconnected;
-
+
watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), this);
QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
@@ -543,7 +543,7 @@ void tst_QDeclarativeDebug::watch_expression()
QFETCH(int, incrementCount);
int origWidth = m_rootItem->property("width").toInt();
-
+
QDeclarativeDebugObjectReference obj = findRootObject();
QDeclarativeDebugObjectExpressionWatch *watch;
@@ -553,12 +553,12 @@ void tst_QDeclarativeDebug::watch_expression()
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
delete watch;
delete unconnected;
-
+
watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), expr, this);
QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
delete watch;
-
+
watch = m_dbg->addWatch(obj, expr, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
QCOMPARE(watch->objectDebugId(), obj.debugId());
@@ -588,7 +588,7 @@ void tst_QDeclarativeDebug::watch_expression()
delete watch;
// restore original value and verify spy doesn't get a signal since watch has been removed
- m_rootItem->setProperty("width", origWidth);
+ m_rootItem->setProperty("width", origWidth);
QTest::qWait(100);
QCOMPARE(spy.count(), expectedSpyCount);
@@ -659,7 +659,7 @@ void tst_QDeclarativeDebug::queryRootContexts()
int engineId = q_engines->engines()[0].debugId();
QDeclarativeDebugRootContextQuery *q_context;
-
+
QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
q_context = unconnected->queryRootContexts(engineId, this);
QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error);
@@ -698,7 +698,7 @@ void tst_QDeclarativeDebug::queryObject()
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
-
+
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
waitForQuery(q_context);
QDeclarativeDebugObjectReference rootObject = q_context->rootContext().objects()[0];
@@ -772,7 +772,7 @@ void tst_QDeclarativeDebug::queryExpressionResult()
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines); // check immediate deletion is ok
-
+
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
waitForQuery(q_context);
int objectId = q_context->rootContext().objects()[0].debugId();
@@ -784,7 +784,7 @@ void tst_QDeclarativeDebug::queryExpressionResult()
QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error);
delete q_expr;
delete unconnected;
-
+
q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
delete q_expr;
@@ -923,7 +923,7 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference()
QDeclarativeDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
waitForQuery(query);
QDeclarativeDebugObjectReference obj = query->object();
- delete query;
+ delete query;
QDeclarativeDebugPropertyReference ref = findProperty(obj.properties(), "scale");
QVERIFY(ref.objectDebugId() > 0);
@@ -932,7 +932,7 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference()
QVERIFY(!ref.valueTypeName().isEmpty());
QVERIFY(!ref.binding().isEmpty());
QVERIFY(ref.hasNotifySignal());
-
+
QDeclarativeDebugPropertyReference copy(ref);
QDeclarativeDebugPropertyReference copyAssign;
copyAssign = ref;
diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
index c182893..59214d1 100644
--- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
+++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
@@ -88,7 +88,7 @@ void tst_QDeclarativeDebugClient::initTestCase()
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
- Q_ASSERT(ok);
+ QVERIFY(ok);
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Enabled);
diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
index 0911a83..a61f4a8 100644
--- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
+++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
@@ -87,7 +87,7 @@ void tst_QDeclarativeDebugService::initTestCase()
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
- Q_ASSERT(ok);
+ QVERIFY(ok);
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
}
diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
index e684bbe..2f0992c 100644
--- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
+++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
@@ -55,13 +55,13 @@
#endif
class tst_qdeclarativefontloader : public QObject
-
{
Q_OBJECT
public:
tst_qdeclarativefontloader();
private slots:
+ void init();
void noFont();
void namedFont();
void localFont();
@@ -71,8 +71,6 @@ private slots:
void failWebFont();
void changeFont();
-private slots:
-
private:
QDeclarativeEngine engine;
TestHTTPServer server;
@@ -82,7 +80,11 @@ tst_qdeclarativefontloader::tst_qdeclarativefontloader() :
server(SERVER_PORT)
{
server.serveDirectory(SRCDIR "/data");
- Q_ASSERT(server.isValid());
+}
+
+void tst_qdeclarativefontloader::init()
+{
+ QVERIFY(server.isValid());
}
void tst_qdeclarativefontloader::noFont()
diff --git a/tests/auto/modeltest/modeltest.cpp b/tests/auto/modeltest/modeltest.cpp
index 98d707c..5ef27f9 100644
--- a/tests/auto/modeltest/modeltest.cpp
+++ b/tests/auto/modeltest/modeltest.cpp
@@ -45,8 +45,6 @@
#include "modeltest.h"
#include <QtTest/QtTest>
-#undef Q_ASSERT
-#define Q_ASSERT QVERIFY
Q_DECLARE_METATYPE ( QModelIndex )
@@ -118,15 +116,15 @@ void ModelTest::runAllTests()
*/
void ModelTest::nonDestructiveBasicTest()
{
- Q_ASSERT ( model->buddy ( QModelIndex() ) == QModelIndex() );
+ QVERIFY( model->buddy ( QModelIndex() ) == QModelIndex() );
model->canFetchMore ( QModelIndex() );
- Q_ASSERT ( model->columnCount ( QModelIndex() ) >= 0 );
- Q_ASSERT ( model->data ( QModelIndex() ) == QVariant() );
+ QVERIFY( model->columnCount ( QModelIndex() ) >= 0 );
+ QVERIFY( model->data ( QModelIndex() ) == QVariant() );
fetchingMore = true;
model->fetchMore ( QModelIndex() );
fetchingMore = false;
Qt::ItemFlags flags = model->flags ( QModelIndex() );
- Q_ASSERT ( flags == Qt::ItemIsDropEnabled || flags == 0 );
+ QVERIFY( flags == Qt::ItemIsDropEnabled || flags == 0 );
model->hasChildren ( QModelIndex() );
model->hasIndex ( 0, 0 );
model->headerData ( 0, Qt::Horizontal );
@@ -135,8 +133,8 @@ void ModelTest::nonDestructiveBasicTest()
QVariant cache;
model->match ( QModelIndex(), -1, cache );
model->mimeTypes();
- Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() );
- Q_ASSERT ( model->rowCount() >= 0 );
+ QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() );
+ QVERIFY( model->rowCount() >= 0 );
QVariant variant;
model->setData ( QModelIndex(), variant, -1 );
model->setHeaderData ( -1, Qt::Horizontal, QVariant() );
@@ -158,17 +156,17 @@ void ModelTest::rowCount()
// check top row
QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
int rows = model->rowCount ( topIndex );
- Q_ASSERT ( rows >= 0 );
+ QVERIFY( rows >= 0 );
if ( rows > 0 )
- Q_ASSERT ( model->hasChildren ( topIndex ) == true );
+ QVERIFY( model->hasChildren ( topIndex ) );
QModelIndex secondLevelIndex = model->index ( 0, 0, topIndex );
if ( secondLevelIndex.isValid() ) { // not the top level
// check a row count where parent is valid
rows = model->rowCount ( secondLevelIndex );
- Q_ASSERT ( rows >= 0 );
+ QVERIFY( rows >= 0 );
if ( rows > 0 )
- Q_ASSERT ( model->hasChildren ( secondLevelIndex ) == true );
+ QVERIFY( model->hasChildren ( secondLevelIndex ) );
}
// The models rowCount() is tested more extensively in checkChildren(),
@@ -182,12 +180,12 @@ void ModelTest::columnCount()
{
// check top row
QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
- Q_ASSERT ( model->columnCount ( topIndex ) >= 0 );
+ QVERIFY( model->columnCount ( topIndex ) >= 0 );
// check a column count where parent is valid
QModelIndex childIndex = model->index ( 0, 0, topIndex );
if ( childIndex.isValid() )
- Q_ASSERT ( model->columnCount ( childIndex ) >= 0 );
+ QVERIFY( model->columnCount ( childIndex ) >= 0 );
// columnCount() is tested more extensively in checkChildren(),
// but this catches the big mistakes
@@ -200,19 +198,19 @@ void ModelTest::hasIndex()
{
// qDebug() << "hi";
// Make sure that invalid values returns an invalid index
- Q_ASSERT ( model->hasIndex ( -2, -2 ) == false );
- Q_ASSERT ( model->hasIndex ( -2, 0 ) == false );
- Q_ASSERT ( model->hasIndex ( 0, -2 ) == false );
+ QVERIFY( !model->hasIndex ( -2, -2 ) );
+ QVERIFY( !model->hasIndex ( -2, 0 ) );
+ QVERIFY( !model->hasIndex ( 0, -2 ) );
int rows = model->rowCount();
int columns = model->columnCount();
// check out of bounds
- Q_ASSERT ( model->hasIndex ( rows, columns ) == false );
- Q_ASSERT ( model->hasIndex ( rows + 1, columns + 1 ) == false );
+ QVERIFY( !model->hasIndex ( rows, columns ) );
+ QVERIFY( !model->hasIndex ( rows + 1, columns + 1 ) );
if ( rows > 0 )
- Q_ASSERT ( model->hasIndex ( 0, 0 ) == true );
+ QVERIFY( model->hasIndex ( 0, 0 ) );
// hasIndex() is tested more extensively in checkChildren(),
// but this catches the big mistakes
@@ -225,9 +223,9 @@ void ModelTest::index()
{
// qDebug() << "i";
// Make sure that invalid values returns an invalid index
- Q_ASSERT ( model->index ( -2, -2 ) == QModelIndex() );
- Q_ASSERT ( model->index ( -2, 0 ) == QModelIndex() );
- Q_ASSERT ( model->index ( 0, -2 ) == QModelIndex() );
+ QVERIFY( model->index ( -2, -2 ) == QModelIndex() );
+ QVERIFY( model->index ( -2, 0 ) == QModelIndex() );
+ QVERIFY( model->index ( 0, -2 ) == QModelIndex() );
int rows = model->rowCount();
int columns = model->columnCount();
@@ -236,13 +234,13 @@ void ModelTest::index()
return;
// Catch off by one errors
- Q_ASSERT ( model->index ( rows, columns ) == QModelIndex() );
- Q_ASSERT ( model->index ( 0, 0 ).isValid() == true );
+ QVERIFY( model->index ( rows, columns ) == QModelIndex() );
+ QVERIFY( model->index ( 0, 0 ).isValid() );
// Make sure that the same index is *always* returned
QModelIndex a = model->index ( 0, 0 );
QModelIndex b = model->index ( 0, 0 );
- Q_ASSERT ( a == b );
+ QVERIFY( a == b );
// index() is tested more extensively in checkChildren(),
// but this catches the big mistakes
@@ -256,7 +254,7 @@ void ModelTest::parent()
// qDebug() << "p";
// Make sure the model wont crash and will return an invalid QModelIndex
// when asked for the parent of an invalid index.
- Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() );
+ QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() );
if ( model->rowCount() == 0 )
return;
@@ -269,13 +267,13 @@ void ModelTest::parent()
// Common error test #1, make sure that a top level index has a parent
// that is a invalid QModelIndex.
QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
- Q_ASSERT ( model->parent ( topIndex ) == QModelIndex() );
+ QVERIFY( model->parent ( topIndex ) == QModelIndex() );
// Common error test #2, make sure that a second level index has a parent
// that is the first level index.
if ( model->rowCount ( topIndex ) > 0 ) {
QModelIndex childIndex = model->index ( 0, 0, topIndex );
- Q_ASSERT ( model->parent ( childIndex ) == topIndex );
+ QVERIFY( model->parent ( childIndex ) == topIndex );
}
// Common error test #3, the second column should NOT have the same children
@@ -285,7 +283,7 @@ void ModelTest::parent()
if ( model->rowCount ( topIndex1 ) > 0 ) {
QModelIndex childIndex = model->index ( 0, 0, topIndex );
QModelIndex childIndex1 = model->index ( 0, 0, topIndex1 );
- Q_ASSERT ( childIndex != childIndex1 );
+ QVERIFY( childIndex != childIndex1 );
}
// Full test, walk n levels deep through the model making sure that all
@@ -325,47 +323,47 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
int columns = model->columnCount ( parent );
if ( rows > 0 )
- Q_ASSERT ( model->hasChildren ( parent ) );
+ QVERIFY( model->hasChildren ( parent ) );
// Some further testing against rows(), columns(), and hasChildren()
- Q_ASSERT ( rows >= 0 );
- Q_ASSERT ( columns >= 0 );
+ QVERIFY( rows >= 0 );
+ QVERIFY( columns >= 0 );
if ( rows > 0 )
- Q_ASSERT ( model->hasChildren ( parent ) == true );
+ QVERIFY( model->hasChildren ( parent ) );
//qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows
// << "columns:" << columns << "parent column:" << parent.column();
- Q_ASSERT ( model->hasIndex ( rows + 1, 0, parent ) == false );
+ QVERIFY( !model->hasIndex ( rows + 1, 0, parent ) );
for ( int r = 0; r < rows; ++r ) {
if ( model->canFetchMore ( parent ) ) {
fetchingMore = true;
model->fetchMore ( parent );
fetchingMore = false;
}
- Q_ASSERT ( model->hasIndex ( r, columns + 1, parent ) == false );
+ QVERIFY( !model->hasIndex ( r, columns + 1, parent ) );
for ( int c = 0; c < columns; ++c ) {
- Q_ASSERT ( model->hasIndex ( r, c, parent ) == true );
+ QVERIFY( model->hasIndex ( r, c, parent ) );
QModelIndex index = model->index ( r, c, parent );
// rowCount() and columnCount() said that it existed...
- Q_ASSERT ( index.isValid() == true );
+ QVERIFY( index.isValid() );
// index() should always return the same index when called twice in a row
QModelIndex modifiedIndex = model->index ( r, c, parent );
- Q_ASSERT ( index == modifiedIndex );
+ QVERIFY( index == modifiedIndex );
// Make sure we get the same index if we request it twice in a row
QModelIndex a = model->index ( r, c, parent );
QModelIndex b = model->index ( r, c, parent );
- Q_ASSERT ( a == b );
+ QVERIFY( a == b );
// Some basic checking on the index that is returned
- Q_ASSERT ( index.model() == model );
- Q_ASSERT ( index.row() == r );
- Q_ASSERT ( index.column() == c );
+ QVERIFY( index.model() == model );
+ QCOMPARE( index.row(), r );
+ QCOMPARE( index.column(), c );
// While you can technically return a QVariant usually this is a sign
- // of an bug in data() Disable if this really is ok in your model.
-// Q_ASSERT ( model->data ( index, Qt::DisplayRole ).isValid() == true );
+ // of a bug in data(). Disable if this really is ok in your model.
+// QVERIFY( model->data ( index, Qt::DisplayRole ).isValid() );
// If the next test fails here is some somewhat useful debug you play with.
@@ -380,8 +378,7 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
}
// Check that we can get back our real parent.
-// qDebug() << model->parent ( index ) << parent ;
- Q_ASSERT ( model->parent ( index ) == parent );
+ QCOMPARE( model->parent ( index ), parent );
// recursively go down the children
if ( model->hasChildren ( index ) && currentDepth < 10 ) {
@@ -391,7 +388,7 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
// make sure that after testing the children that the index doesn't change.
QModelIndex newerIndex = model->index ( r, c, parent );
- Q_ASSERT ( index == newerIndex );
+ QVERIFY( index == newerIndex );
}
}
}
@@ -402,68 +399,68 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
void ModelTest::data()
{
// Invalid index should return an invalid qvariant
- Q_ASSERT ( !model->data ( QModelIndex() ).isValid() );
+ QVERIFY( !model->data ( QModelIndex() ).isValid() );
if ( model->rowCount() == 0 )
return;
// A valid index should have a valid QVariant data
- Q_ASSERT ( model->index ( 0, 0 ).isValid() );
+ QVERIFY( model->index ( 0, 0 ).isValid() );
// shouldn't be able to set data on an invalid index
- Q_ASSERT ( model->setData ( QModelIndex(), QLatin1String ( "foo" ), Qt::DisplayRole ) == false );
+ QVERIFY( !model->setData ( QModelIndex(), QLatin1String ( "foo" ), Qt::DisplayRole ) );
// General Purpose roles that should return a QString
QVariant variant = model->data ( model->index ( 0, 0 ), Qt::ToolTipRole );
if ( variant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
+ QVERIFY( qVariantCanConvert<QString> ( variant ) );
}
variant = model->data ( model->index ( 0, 0 ), Qt::StatusTipRole );
if ( variant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
+ QVERIFY( qVariantCanConvert<QString> ( variant ) );
}
variant = model->data ( model->index ( 0, 0 ), Qt::WhatsThisRole );
if ( variant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
+ QVERIFY( qVariantCanConvert<QString> ( variant ) );
}
// General Purpose roles that should return a QSize
variant = model->data ( model->index ( 0, 0 ), Qt::SizeHintRole );
if ( variant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QSize> ( variant ) );
+ QVERIFY( qVariantCanConvert<QSize> ( variant ) );
}
// General Purpose roles that should return a QFont
QVariant fontVariant = model->data ( model->index ( 0, 0 ), Qt::FontRole );
if ( fontVariant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QFont> ( fontVariant ) );
+ QVERIFY( qVariantCanConvert<QFont> ( fontVariant ) );
}
// Check that the alignment is one we know about
QVariant textAlignmentVariant = model->data ( model->index ( 0, 0 ), Qt::TextAlignmentRole );
if ( textAlignmentVariant.isValid() ) {
int alignment = textAlignmentVariant.toInt();
- Q_ASSERT ( alignment == ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) );
+ QCOMPARE( alignment, ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) );
}
// General Purpose roles that should return a QColor
QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole );
if ( colorVariant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QColor> ( colorVariant ) );
+ QVERIFY( qVariantCanConvert<QColor> ( colorVariant ) );
}
colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole );
if ( colorVariant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QColor> ( colorVariant ) );
+ QVERIFY( qVariantCanConvert<QColor> ( colorVariant ) );
}
// Check that the "check state" is one we know about.
QVariant checkStateVariant = model->data ( model->index ( 0, 0 ), Qt::CheckStateRole );
if ( checkStateVariant.isValid() ) {
int state = checkStateVariant.toInt();
- Q_ASSERT ( state == Qt::Unchecked ||
- state == Qt::PartiallyChecked ||
- state == Qt::Checked );
+ QVERIFY( state == Qt::Unchecked ||
+ state == Qt::PartiallyChecked ||
+ state == Qt::Checked );
}
}
@@ -494,7 +491,7 @@ void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, in
void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end )
{
Changing c = insert.pop();
- Q_ASSERT ( c.parent == parent );
+ QVERIFY( c.parent == parent );
// qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize
// << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent );
@@ -504,8 +501,8 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end )
// }
// qDebug();
- Q_ASSERT ( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) );
- Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
+ QVERIFY( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) );
+ QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
if (c.next != model->data(model->index(end + 1, 0, c.parent))) {
qDebug() << start << end;
@@ -514,7 +511,7 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end )
qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent));
}
- Q_ASSERT ( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) );
+ QVERIFY( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) );
}
void ModelTest::layoutAboutToBeChanged()
@@ -527,7 +524,7 @@ void ModelTest::layoutChanged()
{
for ( int i = 0; i < changing.count(); ++i ) {
QPersistentModelIndex p = changing[i];
- Q_ASSERT ( p == model->index ( p.row(), p.column(), p.parent() ) );
+ QVERIFY( p == model->index ( p.row(), p.column(), p.parent() ) );
}
changing.clear();
}
@@ -557,10 +554,10 @@ void ModelTest::rowsRemoved ( const QModelIndex & parent, int start, int end )
{
qDebug() << "rr" << parent << start << end;
Changing c = remove.pop();
- Q_ASSERT ( c.parent == parent );
- Q_ASSERT ( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) );
- Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
- Q_ASSERT ( c.next == model->data ( model->index ( start, 0, c.parent ) ) );
+ QVERIFY( c.parent == parent );
+ QVERIFY( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) );
+ QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
+ QVERIFY( c.next == model->data ( model->index ( start, 0, c.parent ) ) );
}
diff --git a/tests/auto/q3listview/tst_q3listview.cpp b/tests/auto/q3listview/tst_q3listview.cpp
index 601d74f..c1b3950 100644
--- a/tests/auto/q3listview/tst_q3listview.cpp
+++ b/tests/auto/q3listview/tst_q3listview.cpp
@@ -678,7 +678,7 @@ void tst_Q3ListView::selections_mouseClick()
for (i = 0; i < items.count(); ++i) {
Q3ListViewItem *item = items.at(i);
- Q_ASSERT(item);
+ QVERIFY(item);
if ( item->isSelected() ) {
QVERIFY( selectedItems.contains( i ) );
} else {
diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
index 6f3722d..838fd22 100644
--- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
+++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
@@ -251,7 +251,7 @@ void tst_Q3SqlCursor::copyConstructor()
}
QSqlRecord* rec = cur2.primeUpdate();
- Q_ASSERT( rec );
+ QVERIFY( rec );
QCOMPARE( (int)rec->count(), 4 );
int i = 0;
@@ -398,7 +398,7 @@ void tst_Q3SqlCursor::batchInsert()
int i = 0;
for ( ; i < 100; ++i ) {
QSqlRecord* irec = cur.primeInsert();
- Q_ASSERT( irec );
+ QVERIFY( irec );
irec->setValue( "id", i );
irec->setValue( "t_varchar", "blah" );
irec->setValue( "t_char", "blah" );
@@ -412,7 +412,7 @@ void tst_Q3SqlCursor::batchInsert()
for ( ; i < 200; ++i ) {
QSqlRecord* irec = cur.primeInsert();
- Q_ASSERT( irec );
+ QVERIFY( irec );
irec->setValue( "id", i );
irec->setValue( "t_varchar", "blah" );
irec->setValue( "t_char", "blah" );
@@ -699,7 +699,7 @@ void tst_Q3SqlCursor::updateNoPK()
Q3SqlCursor cur(qTableName("qtestPK", __FILE__), true, db);
QSqlRecord* rec = cur.primeInsert();
- Q_ASSERT(rec);
+ QVERIFY(rec);
rec->setNull(0);
rec->setNull(1);
rec->setNull(2);
@@ -724,7 +724,7 @@ void tst_Q3SqlCursor::updateNoPK()
}
rec = cur.primeUpdate();
- Q_ASSERT(rec);
+ QVERIFY(rec);
rec->setValue(0, 1);
rec->setNull(1);
rec->setNull(2);
diff --git a/tests/auto/qbuffer/tst_qbuffer.cpp b/tests/auto/qbuffer/tst_qbuffer.cpp
index 3e3cc73..5d6b84f 100644
--- a/tests/auto/qbuffer/tst_qbuffer.cpp
+++ b/tests/auto/qbuffer/tst_qbuffer.cpp
@@ -309,8 +309,7 @@ void tst_QBuffer::seekTest()
// (see Task 184730)
{
char c;
- const int offset = 1;
- Q_ASSERT(offset > 0); // any positive integer will do
+ const int offset = 1; // any positive integer will do
const qint64 pos = buf.size() + offset;
QVERIFY(buf.seek(pos));
QCOMPARE(buf.pos(), pos);
diff --git a/tests/auto/qchar/tst_qchar.cpp b/tests/auto/qchar/tst_qchar.cpp
index 45dd7eb..911a30c 100644
--- a/tests/auto/qchar/tst_qchar.cpp
+++ b/tests/auto/qchar/tst_qchar.cpp
@@ -548,14 +548,14 @@ void tst_QChar::normalization_data()
QList<QByteArray> l = line.split(';');
- Q_ASSERT(l.size() == 5);
+ QCOMPARE(l.size(), 5);
QStringList columns;
for (int i = 0; i < 5; ++i) {
columns.append(QString());
QList<QByteArray> c = l.at(i).split(' ');
- Q_ASSERT(!c.isEmpty());
+ QVERIFY(!c.isEmpty());
for (int j = 0; j < c.size(); ++j) {
bool ok;
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index 932c19e..afcc433 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -1248,9 +1248,7 @@ public:
void tst_QCompleter::task189564_omitNonSelectableItems()
{
const QString prefix("a");
- Q_ASSERT(!prefix.isEmpty());
const int n = 5;
- Q_ASSERT(n > 0);
QStringList strings;
for (int i = 0; i < n; ++i)
diff --git a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
index c8c3b90..98632ae 100644
--- a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -2751,7 +2751,7 @@ void tst_QDateTimeEdit::setCurrentSection()
QFETCH(QList<int>, setCurrentSections);
QFETCH(QList<int>, expectedCursorPositions);
- Q_ASSERT(setCurrentSections.size() == expectedCursorPositions.size());
+ QCOMPARE(setCurrentSections.size(), expectedCursorPositions.size());
testWidget->setDisplayFormat(format);
testWidget->setDateTime(dateTime);
#ifdef Q_WS_MAC
diff --git a/tests/auto/qdbusthreading/tst_qdbusthreading.cpp b/tests/auto/qdbusthreading/tst_qdbusthreading.cpp
index bfb806b..142b6c2 100644
--- a/tests/auto/qdbusthreading/tst_qdbusthreading.cpp
+++ b/tests/auto/qdbusthreading/tst_qdbusthreading.cpp
@@ -592,7 +592,7 @@ void tst_QDBusThreading::callbackInAnotherAuxThread()
// wait for the event loop
sem1.release();
sem2.acquire();
- Q_ASSERT(loop);
+ QVERIFY(loop);
// create the second thread
new Thread;
diff --git a/tests/auto/qdirmodel/tst_qdirmodel.cpp b/tests/auto/qdirmodel/tst_qdirmodel.cpp
index 38a6b8a..a6985a4 100644
--- a/tests/auto/qdirmodel/tst_qdirmodel.cpp
+++ b/tests/auto/qdirmodel/tst_qdirmodel.cpp
@@ -641,10 +641,10 @@ void tst_QDirModel::filter()
QDirModel model;
model.setNameFilters(QStringList() << "*.nada");
QModelIndex index = model.index(SRCDIR "test");
- Q_ASSERT(model.rowCount(index) == 0);
+ QCOMPARE(model.rowCount(index), 0);
QModelIndex index2 = model.index(SRCDIR "test/file01.tst");
- Q_ASSERT(!index2.isValid());
- Q_ASSERT(model.rowCount(index) == 0);
+ QVERIFY(!index2.isValid());
+ QCOMPARE(model.rowCount(index), 0);
}
void tst_QDirModel::task244669_remove()
diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp
index 5e9f130..dc3ca52 100644
--- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp
@@ -812,7 +812,7 @@ void tst_QFileDialog2::task239706_editableFilterCombo()
break;
}
}
- Q_ASSERT(filterCombo);
+ QVERIFY(filterCombo);
filterCombo->setEditable(true);
QTest::mouseClick(filterCombo, Qt::LeftButton);
QTest::keyPress(filterCombo, Qt::Key_X);
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 168f75e..269b576 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -10655,7 +10655,7 @@ void tst_QGraphicsItem::deviceCoordinateCache_simpleRotations()
QTRY_VERIFY(view.repaints > 0);
QGraphicsItemCache *itemCache = QGraphicsItemPrivate::get(item)->extraItemCache();
- Q_ASSERT(itemCache);
+ QVERIFY(itemCache);
QPixmapCache::Key currentKey = itemCache->deviceData.value(view.viewport()).key;
// Trigger an update and verify that the cache is unchanged.
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 9ff086c..0927577 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -3594,7 +3594,7 @@ void tst_QGraphicsScene::task160653_selectionChanged()
item->flags() | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
item->setSelected(true);
}
- Q_ASSERT(scene.items().size() > 1);
+ QVERIFY(scene.items().size() > 1);
QCOMPARE(scene.items().size(), scene.selectedItems().size());
QSignalSpy spy(&scene, SIGNAL(selectionChanged()));
diff --git a/tests/auto/qinputdialog/tst_qinputdialog.cpp b/tests/auto/qinputdialog/tst_qinputdialog.cpp
index 1d13eb6..e0317df 100644
--- a/tests/auto/qinputdialog/tst_qinputdialog.cpp
+++ b/tests/auto/qinputdialog/tst_qinputdialog.cpp
@@ -193,12 +193,12 @@ void testGetNumeric(QInputDialog *dialog, SpinBoxType * = 0, ValueType * = 0)
void testGetText(QInputDialog *dialog)
{
QLineEdit *ledit = qFindChild<QLineEdit *>(dialog);
- Q_ASSERT(ledit);
+ QVERIFY(ledit);
QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog);
- Q_ASSERT(bbox);
+ QVERIFY(bbox);
QPushButton *okButton = bbox->button(QDialogButtonBox::Ok);
- Q_ASSERT(okButton);
+ QVERIFY(okButton);
QVERIFY(ledit->hasAcceptableInput());
QCOMPARE(ledit->selectedText(), ledit->text());
@@ -211,12 +211,12 @@ void testGetText(QInputDialog *dialog)
void testGetItem(QInputDialog *dialog)
{
QComboBox *cbox = qFindChild<QComboBox *>(dialog);
- Q_ASSERT(cbox);
+ QVERIFY(cbox);
QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog);
- Q_ASSERT(bbox);
+ QVERIFY(bbox);
QPushButton *okButton = bbox->button(QDialogButtonBox::Ok);
- Q_ASSERT(okButton);
+ QVERIFY(okButton);
QVERIFY(okButton->isEnabled());
const int origIndex = cbox->currentIndex();
@@ -249,7 +249,7 @@ void tst_QInputDialog::timerEvent(QTimerEvent *event)
{
killTimer(event->timerId());
QInputDialog *dialog = qFindChild<QInputDialog *>(parent);
- Q_ASSERT(dialog);
+ QVERIFY(dialog);
if (testFunc)
testFunc(dialog);
dialog->done(doneCode); // cause static function call to return
@@ -270,7 +270,7 @@ void tst_QInputDialog::getInteger()
{
QFETCH(int, min);
QFETCH(int, max);
- Q_ASSERT(min < max);
+ QVERIFY(min < max);
parent = new QWidget;
doneCode = QDialog::Accepted;
testFunc = &tst_QInputDialog::testFuncGetInteger;
@@ -310,7 +310,7 @@ void tst_QInputDialog::getDouble()
QFETCH(double, min);
QFETCH(double, max);
QFETCH(int, decimals);
- Q_ASSERT(min < max && decimals >= 0 && decimals <= 13);
+ QVERIFY(min < max && decimals >= 0 && decimals <= 13);
parent = new QWidget;
doneCode = QDialog::Accepted;
testFunc = &tst_QInputDialog::testFuncGetDouble;
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp
index 16846de..4f0de4c 100644
--- a/tests/auto/qlocale/tst_qlocale.cpp
+++ b/tests/auto/qlocale/tst_qlocale.cpp
@@ -317,7 +317,7 @@ void tst_QLocale::ctor()
TEST_CTOR("en_GB@.bla", English, UnitedKingdom)
TEST_CTOR("en_GB@bla", English, UnitedKingdom)
- Q_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal);
+ QVERIFY(QLocale::Norwegian == QLocale::NorwegianBokmal);
TEST_CTOR("no", Norwegian, Norway)
TEST_CTOR("nb", Norwegian, Norway)
TEST_CTOR("nn", NorwegianNynorsk, Norway)
@@ -397,7 +397,7 @@ void tst_QLocale::emptyCtor()
TEST_CTOR("en_GB@bla", "en_GB")
TEST_CTOR("de", "de_DE")
- Q_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal);
+ QVERIFY(QLocale::Norwegian == QLocale::NorwegianBokmal);
TEST_CTOR("no", "nb_NO")
TEST_CTOR("nb", "nb_NO")
TEST_CTOR("nn", "nn_NO")
diff --git a/tests/auto/qmessagebox/tst_qmessagebox.cpp b/tests/auto/qmessagebox/tst_qmessagebox.cpp
index c11e76c..ed121ce 100644
--- a/tests/auto/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/qmessagebox/tst_qmessagebox.cpp
@@ -609,48 +609,43 @@ void tst_QMessageBox::testSymbols()
button = QMessageBox::FlagMask;
mb1.setText("Foo");
- QString text = mb1.text();
- Q_ASSERT(text == "Foo");
+ QCOMPARE(mb1.text(), "Foo");
icon = mb1.icon();
- Q_ASSERT(icon == QMessageBox::NoIcon);
+ QVERIFY(icon == QMessageBox::NoIcon);
mb1.setIcon(QMessageBox::Question);
- Q_ASSERT(mb1.icon() == QMessageBox::Question);
+ QVERIFY(mb1.icon() == QMessageBox::Question);
QPixmap iconPixmap = mb1.iconPixmap();
mb1.setIconPixmap(iconPixmap);
- Q_ASSERT(mb1.icon() == QMessageBox::NoIcon);
+ QVERIFY(mb1.icon() == QMessageBox::NoIcon);
- QString bt0 = mb1.buttonText(QMessageBox::Ok);
- QString bt1 = mb1.buttonText(QMessageBox::Cancel);
- QString bt2 = mb1.buttonText(QMessageBox::Ok | QMessageBox::Default);
-
- Q_ASSERT(bt0 == "OK");
- Q_ASSERT(bt1.isEmpty());
- Q_ASSERT(bt2.isEmpty());
+ QCOMPARE(mb1.buttonText(QMessageBox::Ok), "OK");
+ QCOMPARE(mb1.buttonText(QMessageBox::Cancel), QString());
+ QCOMPARE(mb1.buttonText(QMessageBox::Ok | QMessageBox::Default), QString());
mb2.setButtonText(QMessageBox::Cancel, "Foo");
mb2.setButtonText(QMessageBox::Ok, "Bar");
mb2.setButtonText(QMessageBox::Ok | QMessageBox::Default, "Baz");
- Q_ASSERT(mb2.buttonText(QMessageBox::Cancel).isEmpty());
- Q_ASSERT(mb2.buttonText(QMessageBox::Ok) == "Bar");
+ QCOMPARE(mb2.buttonText(QMessageBox::Cancel), QString());
+ QCOMPARE(mb2.buttonText(QMessageBox::Ok), "Bar");
- Q_ASSERT(mb3b.buttonText(QMessageBox::Yes).endsWith("Yes"));
- Q_ASSERT(mb3b.buttonText(QMessageBox::YesAll).isEmpty());
- Q_ASSERT(mb3b.buttonText(QMessageBox::Ok).isEmpty());
+ QVERIFY(mb3b.buttonText(QMessageBox::Yes).endsWith("Yes"));
+ QCOMPARE(mb3b.buttonText(QMessageBox::YesAll), QString());
+ QCOMPARE(mb3b.buttonText(QMessageBox::Ok), QString());
mb3b.setButtonText(QMessageBox::Yes, "Blah");
mb3b.setButtonText(QMessageBox::YesAll, "Zoo");
mb3b.setButtonText(QMessageBox::Ok, "Zoo");
- Q_ASSERT(mb3b.buttonText(QMessageBox::Yes) == "Blah");
- Q_ASSERT(mb3b.buttonText(QMessageBox::YesAll).isEmpty());
- Q_ASSERT(mb3b.buttonText(QMessageBox::Ok).isEmpty());
+ QCOMPARE(mb3b.buttonText(QMessageBox::Yes), "Blah");
+ QCOMPARE(mb3b.buttonText(QMessageBox::YesAll), QString());
+ QCOMPARE(mb3b.buttonText(QMessageBox::Ok), QString());
- Q_ASSERT(mb1.textFormat() == Qt::AutoText);
+ QCOMPARE(mb1.textFormat(), Qt::AutoText);
mb1.setTextFormat(Qt::PlainText);
- Q_ASSERT(mb1.textFormat() == Qt::PlainText);
+ QCOMPARE(mb1.textFormat(), Qt::PlainText);
CONVENIENCE_FUNC_SYMS(information);
CONVENIENCE_FUNC_SYMS_EXTRA(information);
@@ -660,7 +655,7 @@ void tst_QMessageBox::testSymbols()
CONVENIENCE_FUNC_SYMS(critical);
QSize sizeHint = mb1.sizeHint();
- Q_ASSERT(sizeHint.width() > 20 && sizeHint.height() > 20);
+ QVERIFY(sizeHint.width() > 20 && sizeHint.height() > 20);
#ifdef QT3_SUPPORT
//test QT3_SUPPORT stuff
@@ -672,8 +667,8 @@ void tst_QMessageBox::testSymbols()
QPixmap pm = QMessageBox::standardIcon(QMessageBox::Question, Qt::GUIStyle(1));
QPixmap pm2 = QMessageBox::standardIcon(QMessageBox::Question);
- Q_ASSERT(pm.toImage() == iconPixmap.toImage());
- Q_ASSERT(pm2.toImage() == iconPixmap.toImage());
+ QVERIFY(pm.toImage() == iconPixmap.toImage());
+ QVERIFY(pm2.toImage() == iconPixmap.toImage());
int ret1 = QMessageBox::message("title", "text");
int ret2 = QMessageBox::message("title", "text", "OK");
@@ -692,10 +687,10 @@ void tst_QMessageBox::testSymbols()
Q_UNUSED(ret5);
QPixmap pm3 = QMessageBox::standardIcon(QMessageBox::NoIcon);
- Q_ASSERT(pm3.isNull());
+ QVERIFY(pm3.isNull());
pm3 = QMessageBox::standardIcon(QMessageBox::Information);
- Q_ASSERT(!pm3.isNull());
+ QVERIFY(!pm3.isNull());
#endif //QT3_SUPPORT
QMessageBox::about(&mb1, "title", "text");
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 4d032e8..198a275 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -1696,8 +1696,8 @@ void tst_QPixmap::fromImageReaderAnimatedGif()
QImageReader referenceReader(path);
QImageReader pixmapReader(path);
- Q_ASSERT(referenceReader.canRead());
- Q_ASSERT(referenceReader.imageCount() > 1);
+ QVERIFY(referenceReader.canRead());
+ QVERIFY(referenceReader.imageCount() > 1);
for (int i = 0; i < referenceReader.imageCount(); ++i) {
QImage refImage = referenceReader.read();
diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp
index 2a8874e..3e0c3ff 100644
--- a/tests/auto/qprocess/tst_qprocess.cpp
+++ b/tests/auto/qprocess/tst_qprocess.cpp
@@ -668,7 +668,7 @@ void tst_QProcess::exitStatus()
QSKIP("This test opens a crash dialog on Windows", SkipSingle);
#endif
- Q_ASSERT(processList.count() == exitStatus.count());
+ QCOMPARE(exitStatus.count(), processList.count());
for (int i = 0; i < processList.count(); ++i) {
process->start(processList.at(i));
QVERIFY(process->waitForStarted(5000));
diff --git a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
index 03e5c0f..1d4745e 100644
--- a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
+++ b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
@@ -106,7 +106,7 @@ void tst_QScriptValueIterator::iterateForward()
QFETCH(QStringList, propertyNames);
QFETCH(QStringList, propertyValues);
QMap<QString, QString> pmap;
- Q_ASSERT(propertyNames.size() == propertyValues.size());
+ QVERIFY(propertyNames.size() == propertyValues.size());
QScriptEngine engine;
QScriptValue object = engine.newObject();
@@ -165,7 +165,7 @@ void tst_QScriptValueIterator::iterateBackward()
QFETCH(QStringList, propertyNames);
QFETCH(QStringList, propertyValues);
QMap<QString, QString> pmap;
- Q_ASSERT(propertyNames.size() == propertyValues.size());
+ QVERIFY(propertyNames.size() == propertyValues.size());
QScriptEngine engine;
QScriptValue object = engine.newObject();
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index bb04621..f25f8e8 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -283,8 +283,8 @@ void tst_QSharedPointer::operators()
QSharedPointer<char> p1;
QSharedPointer<char> p2(new char);
qptrdiff diff = p2.data() - p1.data();
- Q_ASSERT(p1.data() != p2.data());
- Q_ASSERT(diff != 0);
+ QVERIFY(p1.data() != p2.data());
+ QVERIFY(diff != 0);
// operator-
QCOMPARE(p2 - p1.data(), diff);
@@ -867,8 +867,8 @@ void tst_QSharedPointer::differentPointers()
{
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
Data *aBase = aData;
- Q_ASSERT(aData == aBase);
- Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
+ QVERIFY(aData == aBase);
+ QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
QSharedPointer<Data> baseptr = QSharedPointer<Data>(aData);
QSharedPointer<DiffPtrDerivedData> ptr = qSharedPointerCast<DiffPtrDerivedData>(baseptr);
@@ -885,8 +885,8 @@ void tst_QSharedPointer::differentPointers()
{
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
Data *aBase = aData;
- Q_ASSERT(aData == aBase);
- Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
+ QVERIFY(aData == aBase);
+ QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
QSharedPointer<DiffPtrDerivedData> ptr = QSharedPointer<DiffPtrDerivedData>(aData);
QSharedPointer<Data> baseptr = ptr;
@@ -908,8 +908,8 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
{
VirtualDerived *aData = new VirtualDerived;
Data *aBase = aData;
- Q_ASSERT(aData == aBase);
- Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
+ QVERIFY(aData == aBase);
+ QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>(aData);
QSharedPointer<Data> baseptr = qSharedPointerCast<Data>(ptr);
@@ -928,8 +928,8 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
{
VirtualDerived *aData = new VirtualDerived;
Data *aBase = aData;
- Q_ASSERT(aData == aBase);
- Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
+ QVERIFY(aData == aBase);
+ QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>(aData);
QSharedPointer<Data> baseptr = ptr;
@@ -1605,7 +1605,7 @@ void hashAndMapTest()
QVERIFY(it != c.find(Key()));
if (Ordered) {
- Q_ASSERT(k0 < k1);
+ QVERIFY(k0 < k1);
it = c.begin();
QCOMPARE(it.key(), k0);
diff --git a/tests/auto/qsplitter/tst_qsplitter.cpp b/tests/auto/qsplitter/tst_qsplitter.cpp
index 0482661..60be944 100644
--- a/tests/auto/qsplitter/tst_qsplitter.cpp
+++ b/tests/auto/qsplitter/tst_qsplitter.cpp
@@ -1340,14 +1340,14 @@ void tst_QSplitter::task187373_addAbstractScrollAreas()
QFETCH(QString, className);
QFETCH(bool, addInConstructor);
QFETCH(bool, addOutsideConstructor);
- Q_ASSERT(addInConstructor || addOutsideConstructor);
+ QVERIFY(addInConstructor || addOutsideConstructor);
QSplitter *splitter = new QSplitter;
splitter->show();
- Q_ASSERT(splitter->isVisible());
+ QVERIFY(splitter->isVisible());
QAbstractScrollArea *w = task187373_createScrollArea(splitter, className, addInConstructor);
- Q_ASSERT(w);
+ QVERIFY(w);
if (addOutsideConstructor)
splitter->addWidget(w);
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index 4462659..185e046 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -767,7 +767,7 @@ void tst_QSqlDatabase::checkValues(const FieldDef fieldDefs[], QSqlDatabase db)
Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db);
QVERIFY_SQL(cur, select());
QSqlRecord* rec = cur.primeInsert();
- Q_ASSERT(rec);
+ QVERIFY(rec);
rec->setValue("id", pkey++);
int i = 0;
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
@@ -828,7 +828,7 @@ void tst_QSqlDatabase::checkNullValues(const FieldDef fieldDefs[], QSqlDatabase
Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db);
QVERIFY_SQL(cur, select());
QSqlRecord* rec = cur.primeInsert();
- Q_ASSERT(rec);
+ QVERIFY(rec);
rec->setValue("id", pkey++);
int i = 0;
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index abc8d9a..ad7515b 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -3415,9 +3415,9 @@ void tst_QString::fromLatin1Roundtrip()
QFETCH(QString, unicode);
// QtTest safety check:
- Q_ASSERT(latin1.isNull() == unicode.isNull());
- Q_ASSERT(latin1.isEmpty() == unicode.isEmpty());
- Q_ASSERT(latin1.length() == unicode.length());
+ QCOMPARE(latin1.isNull(), unicode.isNull());
+ QCOMPARE(latin1.isEmpty(), unicode.isEmpty());
+ QCOMPARE(latin1.length(), unicode.length());
if (!latin1.isEmpty())
while (latin1.length() < 128) {
@@ -3470,12 +3470,12 @@ void tst_QString::toLatin1Roundtrip()
QFETCH(QString, unicodedst);
// QtTest safety check:
- Q_ASSERT(latin1.isNull() == unicodesrc.isNull());
- Q_ASSERT(latin1.isEmpty() == unicodesrc.isEmpty());
- Q_ASSERT(latin1.length() == unicodesrc.length());
- Q_ASSERT(latin1.isNull() == unicodedst.isNull());
- Q_ASSERT(latin1.isEmpty() == unicodedst.isEmpty());
- Q_ASSERT(latin1.length() == unicodedst.length());
+ QCOMPARE(latin1.isNull(), unicodesrc.isNull());
+ QCOMPARE(latin1.isEmpty(), unicodesrc.isEmpty());
+ QCOMPARE(latin1.length(), unicodesrc.length());
+ QCOMPARE(latin1.isNull(), unicodedst.isNull());
+ QCOMPARE(latin1.isEmpty(), unicodedst.isEmpty());
+ QCOMPARE(latin1.length(), unicodedst.length());
if (!latin1.isEmpty())
while (latin1.length() < 128) {
@@ -3505,12 +3505,12 @@ void tst_QString::stringRef_toLatin1Roundtrip()
QFETCH(QString, unicodedst);
// QtTest safety check:
- Q_ASSERT(latin1.isNull() == unicodesrc.isNull());
- Q_ASSERT(latin1.isEmpty() == unicodesrc.isEmpty());
- Q_ASSERT(latin1.length() == unicodesrc.length());
- Q_ASSERT(latin1.isNull() == unicodedst.isNull());
- Q_ASSERT(latin1.isEmpty() == unicodedst.isEmpty());
- Q_ASSERT(latin1.length() == unicodedst.length());
+ QCOMPARE(latin1.isNull(), unicodesrc.isNull());
+ QCOMPARE(latin1.isEmpty(), unicodesrc.isEmpty());
+ QCOMPARE(latin1.length(), unicodesrc.length());
+ QCOMPARE(latin1.isNull(), unicodedst.isNull());
+ QCOMPARE(latin1.isEmpty(), unicodedst.isEmpty());
+ QCOMPARE(latin1.length(), unicodedst.length());
if (!latin1.isEmpty())
while (latin1.length() < 128) {
diff --git a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
index 6157004..1da0bde 100644
--- a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
+++ b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
@@ -123,14 +123,14 @@ void tst_QTextBoundaryFinder::graphemeBoundaries()
if (test.at(pos).unicode() == 0xf7)
breakPositions.append(strPos);
else
- Q_ASSERT(test.at(pos).unicode() == 0xd7);
+ QVERIFY(test.at(pos).unicode() == 0xd7);
++pos;
if (pos < test.length()) {
- Q_ASSERT(pos < test.length() - 4);
+ QVERIFY(pos < test.length() - 4);
QString hex = test.mid(pos, 4);
bool ok = true;
testString.append(QChar(hex.toInt(&ok, 16)));
- Q_ASSERT(ok);
+ QVERIFY(ok);
pos += 4;
}
++strPos;
@@ -176,14 +176,14 @@ void tst_QTextBoundaryFinder::wordBoundaries()
if (test.at(pos).unicode() == 0xf7)
breakPositions.append(strPos);
else
- Q_ASSERT(test.at(pos).unicode() == 0xd7);
+ QVERIFY(test.at(pos).unicode() == 0xd7);
++pos;
if (pos < test.length()) {
- Q_ASSERT(pos < test.length() - 4);
+ QVERIFY(pos < test.length() - 4);
QString hex = test.mid(pos, 4);
bool ok = true;
testString.append(QChar(hex.toInt(&ok, 16)));
- Q_ASSERT(ok);
+ QVERIFY(ok);
pos += 4;
}
++strPos;
@@ -228,14 +228,14 @@ void tst_QTextBoundaryFinder::sentenceBoundaries()
if (test.at(pos).unicode() == 0xf7)
breakPositions.append(strPos);
else
- Q_ASSERT(test.at(pos).unicode() == 0xd7);
+ QVERIFY(test.at(pos).unicode() == 0xd7);
++pos;
if (pos < test.length()) {
- Q_ASSERT(pos < test.length() - 4);
+ QVERIFY(pos < test.length() - 4);
QString hex = test.mid(pos, 4);
bool ok = true;
testString.append(QChar(hex.toInt(&ok, 16)));
- Q_ASSERT(ok);
+ QVERIFY(ok);
pos += 4;
}
++strPos;
diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp
index 43656c8..d122b0b 100644
--- a/tests/auto/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp
@@ -428,7 +428,7 @@ void tst_QTextCodec::flagCodepointFFFF() const
QString input(ch);
QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
- Q_ASSERT(codec);
+ QVERIFY(codec);
const QByteArray asDecoded(codec->fromUnicode(input));
QCOMPARE(asDecoded, QByteArray("?"));
@@ -465,7 +465,7 @@ void tst_QTextCodec::flagF7808080() const
QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
- Q_ASSERT(codec);
+ QVERIFY(codec);
//QVERIFY(!codec->canEncode(QChar(0x1C0000)));
@@ -482,7 +482,7 @@ void tst_QTextCodec::flagEFBFBF() const
invalidInput[2] = char(0xBF);
const QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
- Q_ASSERT(codec);
+ QVERIFY(codec);
{
//QVERIFY(!codec->canEncode(QChar(0xFFFF)));
@@ -1627,7 +1627,7 @@ void tst_QTextCodec::utf8bom()
QFETCH(QString, result);
QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
- Q_ASSERT(codec);
+ QVERIFY(codec);
QCOMPARE(codec->toUnicode(data.constData(), data.length(), 0), result);
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 35014c9..64d543f 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -7220,8 +7220,7 @@ void tst_QWidget::render_systemClip2()
QFETCH(bool, usePaintEvent);
QFETCH(QColor, expectedColor);
- Q_ASSERT_X(expectedColor != QColor(Qt::red), Q_FUNC_INFO,
- "Qt::red is the reference color for the image, pick another color");
+ QVERIFY2(expectedColor != QColor(Qt::red), "Qt::red is the reference color for the image, pick another color");
class MyWidget : public QWidget
{
diff --git a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
index 62cc4bb..ff6121f 100644
--- a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
+++ b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
@@ -108,7 +108,7 @@ void tst_SuiteTest::runTestSuite() const
/* Run the tests, and serialize the result(as according to XQTSResult.xsd) to standard out. */
TestSuiteResult *const result = ts->runSuite();
- Q_ASSERT(result);
+ QVERIFY(result);
QFile out(m_candidateBaseline);
QVERIFY(out.open(QIODevice::WriteOnly));