summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-06-09 12:04:55 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-06-09 12:54:49 (GMT)
commitb9f5e151b3c0bca74136720c5b42c9a93c8f25a8 (patch)
tree84a1f0668513370ce909dac38b78318cabd5e479 /tests/auto
parent5039d39f3af42d23bba1f1c0ae10365ebcd82b4a (diff)
downloadQt-b9f5e151b3c0bca74136720c5b42c9a93c8f25a8.zip
Qt-b9f5e151b3c0bca74136720c5b42c9a93c8f25a8.tar.gz
Qt-b9f5e151b3c0bca74136720c5b42c9a93c8f25a8.tar.bz2
small improvement/refactor to cssparser
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qcssparser/tst_cssparser.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/tests/auto/qcssparser/tst_cssparser.cpp b/tests/auto/qcssparser/tst_cssparser.cpp
index b41a745..27258b7 100644
--- a/tests/auto/qcssparser/tst_cssparser.cpp
+++ b/tests/auto/qcssparser/tst_cssparser.cpp
@@ -114,11 +114,52 @@ void tst_CssParser::scanner_data()
}
}
+
+static char *tokenName(QCss::TokenType t)
+{
+ switch (t) {
+ case QCss::NONE: return "NONE";
+ case QCss::S: return "S";
+ case QCss::CDO: return "CDO";
+ case QCss::CDC: return "CDC";
+ case QCss::INCLUDES: return "INCLUDES";
+ case QCss::DASHMATCH: return "DASHMATCH";
+ case QCss::LBRACE: return "LBRACE";
+ case QCss::PLUS: return "PLUS";
+ case QCss::GREATER: return "GREATER";
+ case QCss::COMMA: return "COMMA";
+ case QCss::STRING: return "STRING";
+ case QCss::INVALID: return "INVALID";
+ case QCss::IDENT: return "IDENT";
+ case QCss::HASH: return "HASH";
+ case QCss::ATKEYWORD_SYM: return "ATKEYWORD_SYM";
+ case QCss::EXCLAMATION_SYM: return "EXCLAMATION_SYM";
+ case QCss::LENGTH: return "LENGTH";
+ case QCss::PERCENTAGE: return "PERCENTAGE";
+ case QCss::NUMBER: return "NUMBER";
+ case QCss::FUNCTION: return "FUNCTION";
+ case QCss::COLON: return "COLON";
+ case QCss::SEMICOLON: return "SEMICOLON";
+ case QCss::RBRACE: return "RBRACE";
+ case QCss::SLASH: return "SLASH";
+ case QCss::MINUS: return "MINUS";
+ case QCss::DOT: return "DOT";
+ case QCss::STAR: return "STAR";
+ case QCss::LBRACKET: return "LBRACKET";
+ case QCss::RBRACKET: return "RBRACKET";
+ case QCss::EQUAL: return "EQUAL";
+ case QCss::LPAREN: return "LPAREN";
+ case QCss::RPAREN: return "RPAREN";
+ case QCss::OR: return "OR";
+ }
+ return "";
+}
+
static void debug(const QVector<QCss::Symbol> &symbols, int index = -1)
{
qDebug() << "all symbols:";
for (int i = 0; i < symbols.count(); ++i)
- qDebug() << "(" << i << "); Token:" << QCss::Scanner::tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem();
+ qDebug() << "(" << i << "); Token:" << tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem();
if (index != -1)
qDebug() << "failure at index" << index;
}
@@ -160,7 +201,7 @@ void tst_CssParser::scanner()
QCOMPARE(l.count(), 2);
const QString expectedToken = l.at(0);
const QString expectedLexem = l.at(1);
- QString actualToken = QString::fromLatin1(QCss::Scanner::tokenName(symbols.at(i).token));
+ QString actualToken = QString::fromLatin1(tokenName(symbols.at(i).token));
if (actualToken != expectedToken) {
debug(symbols, i);
QCOMPARE(actualToken, expectedToken);