Commit 5d82ba7d authored by hjk's avatar hjk Committed by hjk
Browse files

modeltest: improve debuggability by simpler expressions in asserts

Change-Id: I48286b73510bcbd303eedead69566d8bb776fe42
Reviewed-on: http://codereview.qt.nokia.com/3989

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 991e19b4
...@@ -220,8 +220,11 @@ void ModelTest::index() ...@@ -220,8 +220,11 @@ void ModelTest::index()
return; return;
// Catch off by one errors // Catch off by one errors
Q_ASSERT(model->index(rows, columns) == QModelIndex()); QModelIndex tmp;
Q_ASSERT(model->index(0, 0).isValid() == true); tmp = model->index(rows, columns);
Q_ASSERT(tmp == QModelIndex());
tmp = model->index(0, 0);
Q_ASSERT(tmp.isValid() == true);
// Make sure that the same index is *always* returned // Make sure that the same index is *always* returned
QModelIndex a = model->index(0, 0); QModelIndex a = model->index(0, 0);
...@@ -244,6 +247,8 @@ void ModelTest::parent() ...@@ -244,6 +247,8 @@ void ModelTest::parent()
if (model->rowCount() == 0) if (model->rowCount() == 0)
return; return;
QModelIndex tmp;
// Column 0 | Column 1 | // Column 0 | Column 1 |
// QModelIndex() | | // QModelIndex() | |
// \- topIndex | topIndex1 | // \- topIndex | topIndex1 |
...@@ -252,13 +257,15 @@ void ModelTest::parent() ...@@ -252,13 +257,15 @@ void ModelTest::parent()
// Common error test #1, make sure that a top level index has a parent // Common error test #1, make sure that a top level index has a parent
// that is a invalid QModelIndex. // that is a invalid QModelIndex.
QModelIndex topIndex = model->index(0, 0, QModelIndex()); QModelIndex topIndex = model->index(0, 0, QModelIndex());
Q_ASSERT(model->parent(topIndex) == QModelIndex()); tmp = model->parent(topIndex);
Q_ASSERT(tmp == QModelIndex());
// Common error test #2, make sure that a second level index has a parent // Common error test #2, make sure that a second level index has a parent
// that is the first level index. // that is the first level index.
if (model->rowCount(topIndex) > 0) { if (model->rowCount(topIndex) > 0) {
QModelIndex childIndex = model->index(0, 0, topIndex); QModelIndex childIndex = model->index(0, 0, topIndex);
Q_ASSERT(model->parent(childIndex) == topIndex); tmp = model->parent(childIndex);
Q_ASSERT(tmp == topIndex);
} }
// Common error test #3, the second column should NOT have the same children // Common error test #3, the second column should NOT have the same children
...@@ -292,6 +299,8 @@ void ModelTest::parent() ...@@ -292,6 +299,8 @@ void ModelTest::parent()
*/ */
void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth)
{ {
QModelIndex tmp;
// First just try walking back up the tree. // First just try walking back up the tree.
QModelIndex p = parent; QModelIndex p = parent;
while (p.isValid()) while (p.isValid())
...@@ -366,7 +375,8 @@ void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) ...@@ -366,7 +375,8 @@ void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth)
//qDebug() << "TTT 1: " << model->parent(index); //qDebug() << "TTT 1: " << model->parent(index);
//qDebug() << "TTT 2: " << parent; //qDebug() << "TTT 2: " << parent;
//qDebug() << "TTT 3: " << index; //qDebug() << "TTT 3: " << index;
Q_ASSERT(model->parent(index) == parent); tmp = model->parent(index);
Q_ASSERT(tmp == parent);
// recursively go down the children // recursively go down the children
if (model->hasChildren(index) && currentDepth < 10 ) { if (model->hasChildren(index) && currentDepth < 10 ) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment