diff --git a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp index fcb56fc4154..a04cdd16658 100644 --- a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp +++ b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp @@ -47,6 +47,10 @@ Tests CheckSymbols, the "data provider" of the semantic highlighter. */ +// When adding tests, you may want to set this enum +// in order to print out all found uses. +enum { enableListing = 0 }; + using namespace CPlusPlus; using namespace CppTools; @@ -57,34 +61,27 @@ typedef SemanticHighlighter Highlighting; typedef QList UseList; Q_DECLARE_METATYPE(UseList) +#define CASE_STR(val) case Highlighting::val: return "Highlighting::" # val static QString useKindToString(UseKind useKind) { switch (useKind) { - case Highlighting::Unknown: - return QLatin1String("SemanticHighlighter::Unknown"); - case Highlighting::TypeUse: - return QLatin1String("SemanticHighlighter::TypeUse"); - case Highlighting::LocalUse: - return QLatin1String("SemanticHighlighter::LocalUse"); - case Highlighting::FieldUse: - return QLatin1String("SemanticHighlighter::FieldUse"); - case Highlighting::EnumerationUse: - return QLatin1String("SemanticHighlighter::EnumerationUse"); - case Highlighting::VirtualMethodUse: - return QLatin1String("SemanticHighlighter::VirtualMethodUse"); - case Highlighting::LabelUse: - return QLatin1String("SemanticHighlighter::LabelUse"); - case Highlighting::MacroUse: - return QLatin1String("SemanticHighlighter::MacroUse"); - case Highlighting::FunctionUse: - return QLatin1String("SemanticHighlighter::FunctionUse"); - case Highlighting::PseudoKeywordUse: - return QLatin1String("SemanticHighlighter::PseudoKeywordUse"); + CASE_STR(Unknown); + CASE_STR(TypeUse); + CASE_STR(LocalUse); + CASE_STR(FieldUse); + CASE_STR(EnumerationUse); + CASE_STR(VirtualMethodUse); + CASE_STR(LabelUse); + CASE_STR(MacroUse); + CASE_STR(FunctionUse); + CASE_STR(PseudoKeywordUse); + CASE_STR(StringUse); default: QTest::qFail("Unknown UseKind", __FILE__, __LINE__); return QLatin1String("Unknown UseKind"); } } +#undef CASE_STR // The following two functions are "enhancements" for QCOMPARE(). QT_BEGIN_NAMESPACE @@ -182,14 +179,21 @@ public: { const int resultCount = future.resultCount(); UseList actualUses; + QByteArray expectedInput; + if (enableListing) + expectedInput = _("\n") + _(8, ' ') + "<< (UseList()\n"; for (int i = 0; i < resultCount; ++i) { const Use use = future.resultAt(i); - // When adding tests, you may want to uncomment the - // following line in order to print out all found uses. - // qDebug() << QTest::toString(use); + if (enableListing) + expectedInput += _(12, ' ') + "<< " + _(QTest::toString(use)) + "\n"; actualUses.append(use); } + if (enableListing) { + expectedInput.chop(1); + expectedInput += ')'; + qDebug() << expectedInput; + } // Checks QVERIFY(resultCount > 0); QCOMPARE(resultCount, expectedUsesAll.count());