diff --git a/src/libs/cplusplus/CppRewriter.cpp b/src/libs/cplusplus/CppRewriter.cpp index da87e756aed6e5464b5988838f73d31505bbe3e1..eb392e24073c9d58069072a45c653c545466c8a7 100644 --- a/src/libs/cplusplus/CppRewriter.cpp +++ b/src/libs/cplusplus/CppRewriter.cpp @@ -37,11 +37,12 @@ #include <Overview.h> #include <QtCore/QVarLengthArray> +#include <QtCore/QRegExp> #include <QtCore/QDebug> -using namespace CPlusPlus; +namespace CPlusPlus { -class CPlusPlus::Rewrite +class Rewrite { public: Rewrite(Control *control, SubstitutionEnvironment *env) @@ -414,18 +415,187 @@ FullySpecifiedType UseQualifiedNames::apply(const Name *name, Rewrite *rewrite) } -FullySpecifiedType CPlusPlus::rewriteType(const FullySpecifiedType &type, - SubstitutionEnvironment *env, - Control *control) +FullySpecifiedType rewriteType(const FullySpecifiedType &type, + SubstitutionEnvironment *env, + Control *control) { Rewrite rewrite(control, env); return rewrite.rewriteType(type); } -const Name *CPlusPlus::rewriteName(const Name *name, - SubstitutionEnvironment *env, - Control *control) +const Name *rewriteName(const Name *name, + SubstitutionEnvironment *env, + Control *control) { Rewrite rewrite(control, env); return rewrite.rewriteName(name); } + +// Simplify complicated STL template types, +// such as 'std::basic_string<char,std::char_traits<char>,std::allocator<char> >' +// -> 'std::string' and helpers. + +static QString chopConst(QString type) +{ + while (1) { + if (type.startsWith(QLatin1String("const"))) + type = type.mid(5); + else if (type.startsWith(QLatin1Char(' '))) + type = type.mid(1); + else if (type.endsWith(QLatin1String("const"))) + type.chop(5); + else if (type.endsWith(QLatin1Char(' '))) + type.chop(1); + else + break; + } + return type; +} + +static inline QRegExp stdStringRegExp(const QString &charType) +{ + QString rc = QLatin1String("basic_string<"); + rc += charType; + rc += QLatin1String(",[ ]?std::char_traits<"); + rc += charType; + rc += QLatin1String(">,[ ]?std::allocator<"); + rc += charType; + rc += QLatin1String("> >"); + const QRegExp re(rc); + Q_ASSERT(re.isValid()); + return re; +} + +// Simplify string types in a type +// 'std::set<std::basic_string<char... > >' -> std::set<std::string>' +static inline void simplifyStdString(const QString &charType, const QString &replacement, + QString *type) +{ + QRegExp stringRegexp = stdStringRegExp(charType); + const int replacementSize = replacement.size(); + for (int pos = 0; pos < type->size(); ) { + // Check next match + const int matchPos = stringRegexp.indexIn(*type, pos); + if (matchPos == -1) + break; + const int matchedLength = stringRegexp.matchedLength(); + type->replace(matchPos, matchedLength, replacement); + pos = matchPos + replacementSize; + // If we were inside an 'allocator<std::basic_string..char > >' + // kill the following blank -> 'allocator<std::string>' + if (pos + 1 < type->size() && type->at(pos) == QLatin1Char(' ') + && type->at(pos + 1) == QLatin1Char('>')) + type->remove(pos, 1); + } +} + +// Fix 'std::allocator<std::string >' -> 'std::allocator<std::string>', +// which can happen when replacing/simplifying +static inline QString fixNestedTemplates(QString s) +{ + const int size = s.size(); + if (size > 3 + && s.at(size - 1) == QLatin1Char('>') + && s.at(size - 2) == QLatin1Char(' ') + && s.at(size - 3) != QLatin1Char('>')) + s.remove(size - 2, 1); + return s; +} + +CPLUSPLUS_EXPORT QString simplifySTLType(const QString &typeIn) +{ + QString type = typeIn; + if (type.startsWith("class ")) // MSVC prepends class,struct + type.remove(0, 6); + if (type.startsWith("struct ")) + type.remove(0, 7); + + type.replace(QLatin1Char('*'), QLatin1Char('@')); + + for (int i = 0; i < 10; ++i) { + int start = type.indexOf("std::allocator<"); + if (start == -1) + break; + // search for matching '>' + int pos; + int level = 0; + for (pos = start + 12; pos < type.size(); ++pos) { + int c = type.at(pos).unicode(); + if (c == '<') { + ++level; + } else if (c == '>') { + --level; + if (level == 0) + break; + } + } + const QString alloc = fixNestedTemplates(type.mid(start, pos + 1 - start).trimmed()); + const QString inner = fixNestedTemplates(alloc.mid(15, alloc.size() - 16).trimmed()); + if (inner == QLatin1String("char")) { // std::string + simplifyStdString(QLatin1String("char"), QLatin1String("string"), &type); + } else if (inner == QLatin1String("wchar_t")) { // std::wstring + simplifyStdString(QLatin1String("wchar_t"), QLatin1String("wstring"), &type); + } else if (inner == QLatin1String("unsigned short")) { // std::wstring/MSVC + simplifyStdString(QLatin1String("unsigned short"), QLatin1String("wstring"), &type); + } + // std::vector, std::deque, std::list + const QRegExp re1(QString::fromLatin1("(vector|list|deque)<%1, ?%2\\s*>").arg(inner, alloc)); + Q_ASSERT(re1.isValid()); + if (re1.indexIn(type) != -1) + type.replace(re1.cap(0), QString::fromLatin1("%1<%2>").arg(re1.cap(1), inner)); + + // std::stack + QRegExp stackRE(QString::fromLatin1("stack<%1, ?std::deque<%2> >").arg(inner, inner)); + stackRE.setMinimal(true); + Q_ASSERT(stackRE.isValid()); + if (stackRE.indexIn(type) != -1) + type.replace(stackRE.cap(0), QString::fromLatin1("stack<%1>").arg(inner)); + + // std::set + QRegExp setRE(QString::fromLatin1("set<%1, ?std::less<%2>, ?%3\\s*>").arg(inner, inner, alloc)); + setRE.setMinimal(true); + Q_ASSERT(setRE.isValid()); + if (setRE.indexIn(type) != -1) + type.replace(setRE.cap(0), QString::fromLatin1("set<%1>").arg(inner)); + + // std::map + if (inner.startsWith("std::pair<")) { + // search for outermost ',', split key and value + int pos; + int level = 0; + for (pos = 10; pos < inner.size(); ++pos) { + int c = inner.at(pos).unicode(); + if (c == '<') + ++level; + else if (c == '>') + --level; + else if (c == ',' && level == 0) + break; + } + const QString key = chopConst(inner.mid(10, pos - 10)); + // Get value: MSVC: 'pair<a const ,b>', gcc: 'pair<const a, b>' + if (inner.at(++pos) == QLatin1Char(' ')) + pos++; + QString value = inner.mid(pos, inner.size() - pos - 1).trimmed(); + QRegExp mapRE1(QString("map<%1, ?%2, ?std::less<%3 ?>, ?%4\\s*>") + .arg(key, value, key, alloc)); + mapRE1.setMinimal(true); + Q_ASSERT(mapRE1.isValid()); + if (mapRE1.indexIn(type) != -1) { + type.replace(mapRE1.cap(0), QString("map<%1, %2>").arg(key, value)); + } else { + QRegExp mapRE2(QString("map<const %1, ?%2, ?std::less<const %3>, ?%4\\s*>") + .arg(key, value, key, alloc)); + mapRE2.setMinimal(true); + if (mapRE2.indexIn(type) != -1) { + type.replace(mapRE2.cap(0), QString("map<const %1, %2>").arg(key, value)); + } + } + } + } + type.replace(QLatin1Char('@'), QLatin1Char('*')); + type.replace(QLatin1String(" >"), QLatin1String(">")); + return type; +} + +} // namespace CPlusPlus diff --git a/src/libs/cplusplus/CppRewriter.h b/src/libs/cplusplus/CppRewriter.h index 988b92f3a624dd58d3157152aa5b4c7626617a48..aa5511ecb0c2480caf42c4581ff5700c7d6d2316 100644 --- a/src/libs/cplusplus/CppRewriter.h +++ b/src/libs/cplusplus/CppRewriter.h @@ -104,6 +104,11 @@ CPLUSPLUS_EXPORT const Name *rewriteName(const Name *name, SubstitutionEnvironment *env, Control *control); +// Simplify complicated STL template types, such as +// 'std::basic_string<char,std::char_traits<char>,std::allocator<char> > '-> +// 'std::string'. +CPLUSPLUS_EXPORT QString simplifySTLType(const QString &typeIn); + } // end of namespace CPlusPlus #endif diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index f1463177a8408be40fae910b32722a59cc54c881..e222bcffbe8a408015883dbd79e4c8bef002a0a1 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -43,6 +43,8 @@ #include <utils/qtcassert.h> #include <utils/savedaction.h> +#include <cplusplus/CppRewriter.h> + #include <QtCore/QDebug> #include <QtCore/QEvent> #include <QtCore/QFile> @@ -243,38 +245,6 @@ static QByteArray parentName(const QByteArray &iname) return iname.left(pos); } - -static QString chopConst(QString type) -{ - while (1) { - if (type.startsWith(QLatin1String("const"))) - type = type.mid(5); - else if (type.startsWith(QLatin1Char(' '))) - type = type.mid(1); - else if (type.endsWith(QLatin1String("const"))) - type.chop(5); - else if (type.endsWith(QLatin1Char(' '))) - type.chop(1); - else - break; - } - return type; -} - -static inline QRegExp stdStringRegExp(const QString &charType) -{ - QString rc = QLatin1String("basic_string<"); - rc += charType; - rc += QLatin1String(",[ ]?std::char_traits<"); - rc += charType; - rc += QLatin1String(">,[ ]?std::allocator<"); - rc += charType; - rc += QLatin1String("> >"); - const QRegExp re(rc); - Q_ASSERT(re.isValid()); - return re; -} - static QString niceTypeHelper(const QByteArray &typeIn) { typedef QMap<QByteArray, QString> Cache; @@ -282,100 +252,9 @@ static QString niceTypeHelper(const QByteArray &typeIn) const Cache::const_iterator it = cache.constFind(typeIn); if (it != cache.constEnd()) return it.value(); - - QString type = QString::fromUtf8(typeIn); - type.replace(QLatin1Char('*'), QLatin1Char('@')); - - for (int i = 0; i < 10; ++i) { - int start = type.indexOf("std::allocator<"); - if (start == -1) - break; - // search for matching '>' - int pos; - int level = 0; - for (pos = start + 12; pos < type.size(); ++pos) { - int c = type.at(pos).unicode(); - if (c == '<') { - ++level; - } else if (c == '>') { - --level; - if (level == 0) - break; - } - } - QString alloc = type.mid(start, pos + 1 - start).trimmed(); - QString inner = alloc.mid(15, alloc.size() - 16).trimmed(); - - if (inner == QLatin1String("char")) { // std::string - const QRegExp stringRegexp = stdStringRegExp(inner); - type.replace(stringRegexp, QLatin1String("string")); - } else if (inner == QLatin1String("wchar_t")) { // std::wstring - const QRegExp wchartStringRegexp = stdStringRegExp(inner); - type.replace(wchartStringRegexp, QLatin1String("wstring")); - } else if (inner == QLatin1String("unsigned short")) { // std::wstring/MSVC - const QRegExp usStringRegexp = stdStringRegExp(inner); - type.replace(usStringRegexp, QLatin1String("wstring")); - } - // std::vector, std::deque, std::list - const QRegExp re1(QString::fromLatin1("(vector|list|deque)<%1, ?%2\\s*>").arg(inner, alloc)); - Q_ASSERT(re1.isValid()); - if (re1.indexIn(type) != -1) - type.replace(re1.cap(0), QString::fromLatin1("%1<%2>").arg(re1.cap(1), inner)); - - // std::stack - QRegExp re6(QString::fromLatin1("stack<%1, ?std::deque<%2> >").arg(inner, inner)); - if (!re6.isMinimal()) - re6.setMinimal(true); - Q_ASSERT(re6.isValid()); - if (re6.indexIn(type) != -1) - type.replace(re6.cap(0), QString::fromLatin1("stack<%1>").arg(inner)); - - // std::set - QRegExp re4(QString::fromLatin1("set<%1, ?std::less<%2>, ?%3\\s*>").arg(inner, inner, alloc)); - if (!re4.isMinimal()) - re4.setMinimal(true); - Q_ASSERT(re4.isValid()); - if (re4.indexIn(type) != -1) - type.replace(re4.cap(0), QString::fromLatin1("set<%1>").arg(inner)); - - // std::map - if (inner.startsWith("std::pair<")) { - // search for outermost ',' - int pos; - int level = 0; - for (pos = 10; pos < inner.size(); ++pos) { - int c = inner.at(pos).unicode(); - if (c == '<') - ++level; - else if (c == '>') - --level; - else if (c == ',' && level == 0) - break; - } - QString ckey = inner.mid(10, pos - 10); - QString key = chopConst(ckey); - QString value = inner.mid(pos + 2, inner.size() - 3 - pos).trimmed(); - QRegExp re5(QString("map<%1, ?%2, ?std::less<%3 ?>, ?%4\\s*>") - .arg(key, value, key, alloc)); - if (!re5.isMinimal()) - re5.setMinimal(true); - Q_ASSERT(re5.isValid()); - if (re5.indexIn(type) != -1) { - type.replace(re5.cap(0), QString("map<%1, %2>").arg(key, value)); - } else { - QRegExp re7(QString("map<const %1, ?%2, ?std::less<const %3>, ?%4\\s*>") - .arg(key, value, key, alloc)); - if (!re7.isMinimal()) - re7.setMinimal(true); - if (re7.indexIn(type) != -1) - type.replace(re7.cap(0), QString("map<const %1, %2>").arg(key, value)); - } - } - } - type.replace(QLatin1Char('@'), QLatin1Char('*')); - type.replace(QLatin1String(" >"), QLatin1String(">")); - cache.insert(typeIn, type); // For simplicity, also cache unmodified types - return type; + const QString simplified = CPlusPlus::simplifySTLType(typeIn); + cache.insert(typeIn, simplified); // For simplicity, also cache unmodified types + return simplified; } QString WatchModel::displayType(const WatchData &data) const diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index fdb016f161b78e2e9f70f702b1fa65322f6daf66..190775c40b05633de973f045ac2fcabfd7374b28 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -228,6 +228,30 @@ void WatchWindow::mouseDoubleClickEvent(QMouseEvent *ev) QTreeView::mouseDoubleClickEvent(ev); } +// Text for add watch action with truncated expression +static inline QString addWatchActionText(QString exp) +{ + if (exp.isEmpty()) + return WatchWindow::tr("Watch Expression"); + if (exp.size() > 30) { + exp.truncate(30); + exp.append(QLatin1String("...")); + } + return WatchWindow::tr("Watch Expression \"%1\"").arg(exp); +} + +// Text for add watch action with truncated expression +static inline QString removeWatchActionText(QString exp) +{ + if (exp.isEmpty()) + return WatchWindow::tr("Remove Watch Expression"); + if (exp.size() > 30) { + exp.truncate(30); + exp.append(QLatin1String("...")); + } + return WatchWindow::tr("Remove Watch Expression \"%1\"").arg(exp); +} + void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) { DebuggerEngine *engine = currentEngine(); @@ -369,15 +393,11 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) tr("Setting a watchpoint on an address will cause the program " "to stop when the data at the address it modified.")); - QString actionName = exp.isEmpty() ? tr("Watch Expression") - : tr("Watch Expression \"%1\"").arg(exp); - QAction *actWatchExpression = new QAction(actionName, &menu); + QAction *actWatchExpression = new QAction(addWatchActionText(exp), &menu); actWatchExpression->setEnabled(canHandleWatches && !exp.isEmpty()); // Can remove watch if engine can handle it or session engine. - actionName = exp.isEmpty() ? tr("Remove Watch Expression") - : tr("Remove Watch Expression \"%1\"").arg(exp); - QAction *actRemoveWatchExpression = new QAction(actionName, &menu); + QAction *actRemoveWatchExpression = new QAction(removeWatchActionText(exp), &menu); actRemoveWatchExpression->setEnabled( (canHandleWatches || state == DebuggerNotReady) && !exp.isEmpty()); diff --git a/tests/auto/cplusplus/cplusplus.pro b/tests/auto/cplusplus/cplusplus.pro index 5e22168423ebea18edf6d2cd3d47cc970116ff86..0c16c670287976202890a46a27c1238857ef3537 100644 --- a/tests/auto/cplusplus/cplusplus.pro +++ b/tests/auto/cplusplus/cplusplus.pro @@ -9,4 +9,6 @@ SUBDIRS = \ lookup \ preprocessor \ semantic \ - typeprettyprinter + typeprettyprinter \ + simplifytypes + diff --git a/tests/auto/cplusplus/simplifytypes/simplifytypes.pro b/tests/auto/cplusplus/simplifytypes/simplifytypes.pro new file mode 100644 index 0000000000000000000000000000000000000000..587abf8146405c65d3c927cbcd7e8f99df88cbb8 --- /dev/null +++ b/tests/auto/cplusplus/simplifytypes/simplifytypes.pro @@ -0,0 +1,3 @@ +include(../../qttest.pri) +include(../shared/shared.pri) +SOURCES += tst_simplifytypestest.cpp diff --git a/tests/auto/cplusplus/simplifytypes/tst_simplifytypestest.cpp b/tests/auto/cplusplus/simplifytypes/tst_simplifytypestest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aaa51bf5fd11bc677b7af36b7722e6f5ae186b89 --- /dev/null +++ b/tests/auto/cplusplus/simplifytypes/tst_simplifytypestest.cpp @@ -0,0 +1,139 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include <cplusplus/CppRewriter.h> + +#include <QtCore/QString> +#include <QtTest/QtTest> + +const char *description[] = +{ + "g++_stdstring", + "g++_stdwstring", + "g++_stringmap", + "g++_wstringmap", + "g++_stringlist", + "g++_stringset", + "g++_stringvector", + "g++_wstringvector", + "msvc_stdstring", + "msvc_stdwstring", + "msvc_stringmap", + "msvc_wstringmap", + "msvc_stringlist", + "msvc_stringset", + "msvc_stringvector", + "msvc_wstringvector", +}; + +const char *input[] = +{ +// g++ +"std::string", +"std::wstring", +"std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >", +"std::map<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, std::less<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, std::allocator<std::pair<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > >", +"std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >", +"std::set<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >", +"std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >", +"std::vector<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, std::allocator<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > >", +// MSVC +"class std::basic_string<char,std::char_traits<char>,std::allocator<char> >", +"class std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >", +"class std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >", +"class std::map<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >,std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >,std::less<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> > >,std::allocator<std::pair<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> > const ,std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> > > > >", +"class std::list<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >", +"class std::set<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >", +"class std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >", +"class std::vector<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >,std::allocator<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> > > >" +}; + +const char *output[] = +{ + "std::string", + "std::wstring", + "std::map<std::string, std::string>", + "std::map<std::wstring, std::wstring>", + "std::list<std::string>", + "std::set<std::string>", + "std::vector<std::string>", + "std::vector<std::wstring>", + "std::string", + "std::wstring", + "std::map<std::string, std::string>", + "std::map<std::wstring, std::wstring>", + "std::list<std::string>", + "std::set<std::string>", + "std::vector<std::string>", + "std::vector<std::wstring>", +}; + +class SimplifyTypesTest : public QObject +{ + Q_OBJECT + +public: + SimplifyTypesTest(); + +private Q_SLOTS: + void testCase1(); + void testCase1_data(); +}; + +SimplifyTypesTest::SimplifyTypesTest() +{ +} + +void SimplifyTypesTest::testCase1() +{ + QFETCH(QString, input); + QFETCH(QString, expected); + const QString output = CPlusPlus::simplifySTLType(input); + const bool ok = output == expected; + if (!ok) { + const QString msg = QString::fromAscii("Failure: got '%1' where '%2' was expected for '%3'") + .arg(output, expected, input); + QWARN(qPrintable(msg)); + } + QVERIFY2(ok, "Failure"); +} + +void SimplifyTypesTest::testCase1_data() +{ + QTest::addColumn<QString>("input"); + QTest::addColumn<QString>("expected"); + const size_t count = sizeof(input)/sizeof(const char *); + for (size_t i = 0; i < count; i++ ) + QTest::newRow(description[i]) << QString::fromAscii(input[i]) + << QString::fromAscii(output[i]); +} + +QTEST_APPLESS_MAIN(SimplifyTypesTest); + +#include "tst_simplifytypestest.moc"