Blow up earlier when adding test rows without columns.
authorRobin Burchell <robin.burchell@collabora.com>
Thu, 19 Jan 2012 23:55:51 +0000 (01:55 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 23 Jan 2012 05:49:12 +0000 (06:49 +0100)
Previously, the assertation triggered was rather unhelpful:
 QFATAL : tst_QHash::qhash_qt4() ASSERT: "d->dataCount <
  d->parent->elementCount()" in file qtestdata.cpp,  line 88"

We now try a bit harder to be user-friendly.

Change-Id: I2e3a5ae27914d44fc1dc89af2a084e3d798fe221
Reviewed-by: Jonas Gastal <jgastal@profusion.mobi>
Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
src/testlib/qtestcase.cpp

index 666a0e8..0c2fe2d 100644 (file)
@@ -2286,6 +2286,7 @@ QTestData &QTest::newRow(const char *dataTag)
     QTEST_ASSERT_X(dataTag, "QTest::newRow()", "Data tag can not be null");
     QTestTable *tbl = QTestTable::currentTestTable();
     QTEST_ASSERT_X(tbl, "QTest::newRow()", "Cannot add testdata outside of a _data slot.");
+    QTEST_ASSERT_X(tbl->elementCount(), "QTest::newRow()", "Must add columns before attempting to add rows.");
 
     return *tbl->newData(dataTag);
 }