diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-05-06 05:12:03 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2011-05-09 08:24:49 (GMT) |
commit | b7d421da6d5e945b74ffbc3a7aa635a6ce63ebda (patch) | |
tree | 36c56f73865696bd52e0410fa0832c22d1bea7b0 /tests/auto/qitemmodel/modelstotest.cpp | |
parent | 8d2127d44e6c8af6b041688376de0e5747a1810a (diff) | |
download | Qt-b7d421da6d5e945b74ffbc3a7aa635a6ce63ebda.zip Qt-b7d421da6d5e945b74ffbc3a7aa635a6ce63ebda.tar.gz Qt-b7d421da6d5e945b74ffbc3a7aa635a6ce63ebda.tar.bz2 |
Remove Q_ASSERT from qitemmodel autotest
Don't perform actions needed for the test inside Q_ASSERT, because these
actions won't happen in a non-debug build.
Change-Id: I0758e9f29f38c1a83a1501357286877f05beb6c8
Task-number: QTBUG-17582
Reviewed-by: Rohan McGovern
Diffstat (limited to 'tests/auto/qitemmodel/modelstotest.cpp')
-rw-r--r-- | tests/auto/qitemmodel/modelstotest.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/tests/auto/qitemmodel/modelstotest.cpp b/tests/auto/qitemmodel/modelstotest.cpp index 4e63307..7ebf2c7 100644 --- a/tests/auto/qitemmodel/modelstotest.cpp +++ b/tests/auto/qitemmodel/modelstotest.cpp @@ -313,10 +313,17 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) } if (QDirModel *dirModel = qobject_cast<QDirModel *>(model)) { - // Don't risk somthing bad happening, assert if this fails - Q_ASSERT(QDir(QDir::currentPath()).mkdir("test")); - for (int i = 0; i < 26; ++i) - Q_ASSERT(QDir(QDir::currentPath()).mkdir(QString("test/foo_%1").arg(i))); + if (!QDir::current().mkdir("test")) + qFatal("%s: cannot create directory %s", + Q_FUNC_INFO, + qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/test"))); + for (int i = 0; i < 26; ++i) { + QString subdir = QString("test/foo_%1").arg(i); + if (!QDir::current().mkdir(subdir)) + qFatal("%s: cannot create directory %s", + Q_FUNC_INFO, + qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/"+subdir))); + } return dirModel->index(QDir::currentPath()+"/test"); } @@ -386,9 +393,17 @@ void ModelsToTest::cleanupTestArea(QAbstractItemModel *model) { if (QDir(QDir::currentPath()+"/test").exists()) { - for (int i = 0; i < 26; ++i) - QDir::current().rmdir(QString("test/foo_%1").arg(i)); - Q_ASSERT(QDir::current().rmdir("test")); + for (int i = 0; i < 26; ++i) { + QString subdir(QString("test/foo_%1").arg(i)); + if (!QDir::current().rmdir(subdir)) + qFatal("%s: cannot remove directory %s", + Q_FUNC_INFO, + qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/"+subdir))); + } + if (!QDir::current().rmdir("test")) + qFatal("%s: cannot remove directory %s", + Q_FUNC_INFO, + qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/test"))); } } else if (qobject_cast<QSqlQueryModel *>(model)) { QSqlQuery q("DROP TABLE test"); |