Clarify assert on use of const char* as TestData type in tests.
Currently all C-style strings used as data types in QTest::addColumn will assert at runtime with, e.g.: "expected data of type 'const char*', got 'QString' for element 0 of data with tab 'blah'". This patch makes it clear that C-style strings are disallowed. Change-Id: Iadbb8f10e16607de95c7adb43d9ff3310aac6738 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>bb10
parent
811bf4da67
commit
7cbdac1362
|
|
@ -47,6 +47,7 @@
|
|||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qnamespace.h>
|
||||
#include <QtCore/qmetatype.h>
|
||||
#include <QtCore/qtypetraits.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -218,6 +219,8 @@ namespace QTest
|
|||
template <typename T>
|
||||
inline void addColumn(const char *name, T * = 0)
|
||||
{
|
||||
typedef QtPrivate::is_same<T, const char*> QIsSameTConstChar;
|
||||
Q_STATIC_ASSERT_X(!QIsSameTConstChar::value, "const char* is not allowed as a test data format.");
|
||||
addColumnInternal(qMetaTypeId<T>(), name);
|
||||
}
|
||||
Q_TESTLIB_EXPORT QTestData &newRow(const char *dataTag);
|
||||
|
|
|
|||
Loading…
Reference in New Issue