summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2017-01-16 15:02:43 +0100
committerDavid Faure <david.faure@kdab.com>2017-02-02 12:13:06 +0000
commita9cb5e1ab61fd3655424825ccece94be5aafc77f (patch)
treef33302724d20bfa4a78e02db0036031627cf30e6 /tests
parentc02d429d7f74d11409105b72e29ffd479457b4df (diff)
modeltest: improve debugging
- QCOMPARE takes (actual, expected) rather than the other way around - Added a qWarning with more details before a QVERIFY Change-Id: I0a903a54db28ff2de1f684a2dd9abba3660ee916 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/other/modeltest/modeltest.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/auto/other/modeltest/modeltest.cpp b/tests/auto/other/modeltest/modeltest.cpp
index 76d23d0091..611f9e904b 100644
--- a/tests/auto/other/modeltest/modeltest.cpp
+++ b/tests/auto/other/modeltest/modeltest.cpp
@@ -338,6 +338,8 @@ void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth)
QVERIFY(model->hasIndex(r, c, parent));
QModelIndex index = model->index(r, c, parent);
// rowCount() and columnCount() said that it existed...
+ if (!index.isValid())
+ qWarning() << "Got invalid index at row=" << r << "col=" << c << "parent=" << parent;
QVERIFY(index.isValid());
// index() should always return the same index when called twice in a row
@@ -485,7 +487,7 @@ void ModelTest::rowsAboutToBeInserted(const QModelIndex &parent, int start, int
void ModelTest::rowsInserted(const QModelIndex &parent, int start, int end)
{
Changing c = insert.pop();
- QCOMPARE(c.parent, parent);
+ QCOMPARE(parent, c.parent);
// qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize
// << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent );
@@ -495,8 +497,8 @@ void ModelTest::rowsInserted(const QModelIndex &parent, int start, int end)
// }
// qDebug();
- QCOMPARE(c.oldSize + (end - start + 1), model->rowCount(parent));
- QCOMPARE(c.last, model->data(model->index(start - 1, 0, c.parent)));
+ QCOMPARE(model->rowCount(parent), c.oldSize + (end - start + 1));
+ QCOMPARE(model->data(model->index(start - 1, 0, c.parent)), c.last);
if (c.next != model->data(model->index(end + 1, 0, c.parent))) {
qDebug() << start << end;
@@ -505,7 +507,7 @@ void ModelTest::rowsInserted(const QModelIndex &parent, int start, int end)
qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent));
}
- QCOMPARE(c.next, model->data(model->index(end + 1, 0, c.parent)));
+ QCOMPARE(model->data(model->index(end + 1, 0, c.parent)), c.next);
}
void ModelTest::layoutAboutToBeChanged()
@@ -518,7 +520,7 @@ void ModelTest::layoutChanged()
{
for (int i = 0; i < changing.count(); ++i) {
QPersistentModelIndex p = changing[i];
- QCOMPARE(QModelIndex(p), model->index(p.row(), p.column(), p.parent()));
+ QCOMPARE(model->index(p.row(), p.column(), p.parent()), QModelIndex(p));
}
changing.clear();
}
@@ -548,10 +550,10 @@ void ModelTest::rowsRemoved(const QModelIndex &parent, int start, int end)
{
qDebug() << "rr" << parent << start << end;
Changing c = remove.pop();
- QCOMPARE(c.parent, parent);
- QCOMPARE(c.oldSize - (end - start + 1), model->rowCount(parent));
- QCOMPARE(c.last, model->data(model->index(start - 1, 0, c.parent)));
- QCOMPARE(c.next, model->data(model->index(start, 0, c.parent)));
+ QCOMPARE(parent, c.parent);
+ QCOMPARE(model->rowCount(parent), c.oldSize - (end - start + 1));
+ QCOMPARE(model->data(model->index(start - 1, 0, c.parent)), c.last);
+ QCOMPARE(model->data(model->index(start, 0, c.parent)), c.next);
}
void ModelTest::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)