Commit e51fbd20 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

C++: Fix debugging of lexer test



spell() crashes if identifier is not properly created

Change-Id: I1c3949c3fed2282d893914fa2922f6c281d1f8cd
Reviewed-by: default avatarPrzemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 15680ebe
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include <QtTest> #include <QtTest>
#include <QDebug> #include <QDebug>
//#define DEBUG_TOKENS
typedef QList<unsigned> List; typedef QList<unsigned> List;
Q_DECLARE_METATYPE(List) Q_DECLARE_METATYPE(List)
...@@ -61,12 +63,13 @@ void tst_SimpleLexer::basic() ...@@ -61,12 +63,13 @@ void tst_SimpleLexer::basic()
for (; i < tokenList.size(); ++i) { for (; i < tokenList.size(); ++i) {
QVERIFY2(i < expectedTokenKindList.size(), "More tokens than expected."); QVERIFY2(i < expectedTokenKindList.size(), "More tokens than expected.");
// Compare spelled tokens to have it more readable
const Token token = tokenList.at(i); const Token token = tokenList.at(i);
const unsigned expectedTokenKind = expectedTokenKindList.at(i); const unsigned expectedTokenKind = expectedTokenKindList.at(i);
Token expectedToken; // Create a Token in order to spell the token kind #ifdef DEBUG_TOKENS
expectedToken.f.kind = expectedTokenKind; qDebug("Comparing (i=%d): \"%s\" \"%s\"", i,
// qDebug("Comparing (i=%d): \"%s\" \"%s\"", i, token.spell(), expectedToken.spell()); Token::name(token.kind()),
Token::name(expectedTokenKind));
#endif
QCOMPARE(token.kind(), expectedTokenKind); QCOMPARE(token.kind(), expectedTokenKind);
} }
QVERIFY2(i == expectedTokenKindList.size(), "Less tokens than expected."); QVERIFY2(i == expectedTokenKindList.size(), "Less tokens than expected.");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment