forked from qt-creator/qt-creator
C++: Produce copyable debug output in CheckSymbols test
Change-Id: I338352eaf6372316d2dc8f0f3ad961b7e8d8cbdc Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
09417c56bd
commit
3ab5527a83
@@ -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<Use> 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());
|
||||
|
Reference in New Issue
Block a user