From 7cbdac13627b8e6ba9ed1bcd42fdf3f408f02b7d Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 28 Sep 2012 16:23:09 +0200 Subject: Clarify assert on use of const char* as TestData type in tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/testlib/qtestcase.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/testlib/qtestcase.h') 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 #include #include +#include #include @@ -218,6 +219,8 @@ namespace QTest template inline void addColumn(const char *name, T * = 0) { + typedef QtPrivate::is_same QIsSameTConstChar; + Q_STATIC_ASSERT_X(!QIsSameTConstChar::value, "const char* is not allowed as a test data format."); addColumnInternal(qMetaTypeId(), name); } Q_TESTLIB_EXPORT QTestData &newRow(const char *dataTag); -- cgit v1.2.3