diff options
author | Mitch Curtis <mitch.curtis@digia.com> | 2012-09-28 16:23:09 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-24 01:38:51 +0200 |
commit | 7cbdac13627b8e6ba9ed1bcd42fdf3f408f02b7d (patch) | |
tree | c6e38cc02bf665e97edc9a54d692618f6611329c /src/testlib/qtestcase.h | |
parent | 811bf4da67cedea0daa40f2fff805003687e9d6e (diff) |
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>
Diffstat (limited to 'src/testlib/qtestcase.h')
-rw-r--r-- | src/testlib/qtestcase.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 1bfefaf2b0..8529791be4 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -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); |