forked from qt-creator/qt-creator
C++: Fix debugging of lexer test
spell() crashes if identifier is not properly created Change-Id: I1c3949c3fed2282d893914fa2922f6c281d1f8cd Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
15680ebe0c
commit
e51fbd2009
@@ -33,6 +33,8 @@
|
||||
#include <QtTest>
|
||||
#include <QDebug>
|
||||
|
||||
//#define DEBUG_TOKENS
|
||||
|
||||
typedef QList<unsigned> List;
|
||||
|
||||
Q_DECLARE_METATYPE(List)
|
||||
@@ -61,12 +63,13 @@ void tst_SimpleLexer::basic()
|
||||
for (; i < tokenList.size(); ++i) {
|
||||
QVERIFY2(i < expectedTokenKindList.size(), "More tokens than expected.");
|
||||
|
||||
// Compare spelled tokens to have it more readable
|
||||
const Token token = tokenList.at(i);
|
||||
const unsigned expectedTokenKind = expectedTokenKindList.at(i);
|
||||
Token expectedToken; // Create a Token in order to spell the token kind
|
||||
expectedToken.f.kind = expectedTokenKind;
|
||||
// qDebug("Comparing (i=%d): \"%s\" \"%s\"", i, token.spell(), expectedToken.spell());
|
||||
#ifdef DEBUG_TOKENS
|
||||
qDebug("Comparing (i=%d): \"%s\" \"%s\"", i,
|
||||
Token::name(token.kind()),
|
||||
Token::name(expectedTokenKind));
|
||||
#endif
|
||||
QCOMPARE(token.kind(), expectedTokenKind);
|
||||
}
|
||||
QVERIFY2(i == expectedTokenKindList.size(), "Less tokens than expected.");
|
||||
|
||||
Reference in New Issue
Block a user