preprocessor: some code style in auto test

Change-Id: I1381ce17098a87dbc3924dc86902d7cc1b1eec76
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2012-04-24 18:29:09 +02:00
committed by hjk
parent b834de670d
commit 7f1f282111

View File

@@ -75,20 +75,23 @@ struct Include
Client::IncludeType type;
unsigned line;
};
QDebug &operator<<(QDebug& d, const Include &i) {
QDebug &operator<<(QDebug& d, const Include &i)
{
d << '[' << i.fileName
<< ',' << (i.type == Client::IncludeGlobal ? "Global" : (i.type == Client::IncludeLocal ? "Local" : "Unknown"))
<< ',' << (i.type == Client::IncludeGlobal ? "Global"
: (i.type == Client::IncludeLocal ? "Local" : "Unknown"))
<< ',' << i.line
<< ']';
return d;
}
class MockClient: public Client
class MockClient : public Client
{
public:
struct Block {
Block(): start(0), end(0) {}
Block(unsigned start): start(start), end(0) {}
Block() : start(0), end(0) {}
Block(unsigned start) : start(start), end(0) {}
unsigned start;
unsigned end;
@@ -123,8 +126,7 @@ public:
m_expandedMacrosOffset.append(offset);
}
virtual void stopExpandingMacro(unsigned /*offset*/,
const Macro &/*macro*/) {}
virtual void stopExpandingMacro(unsigned /*offset*/, const Macro &/*macro*/) {}
virtual void startSkippingBlocks(unsigned offset)
{ m_skippedBlocks.append(Block(offset)); }
@@ -163,7 +165,7 @@ public:
}
QString resolveLocally(const QString &currentFileName,
const QString &includedFileName) const
const QString &includedFileName) const
{
QDir dir;
if (currentFileName.isEmpty())
@@ -266,9 +268,13 @@ namespace QTest {
}
QT_END_NAMESPACE
QDebug &operator<<(QDebug& d, const MockClient::Block &b) { d << '[' << b.start << ',' << b.end << ']'; return d; }
QDebug &operator<<(QDebug& d, const MockClient::Block &b)
{
d << '[' << b.start << ',' << b.end << ']';
return d;
}
class tst_Preprocessor: public QObject
class tst_Preprocessor : public QObject
{
Q_OBJECT
@@ -318,15 +324,18 @@ QString tst_Preprocessor::simplified(QByteArray buf)
{
QString out;
QList<QByteArray> lines = buf.split('\n');
foreach (QByteArray line, lines)
foreach (const QByteArray &line, lines) {
if (!line.startsWith('#')) {
out.append(' ');
out.append(line);
}
}
out = out.simplified();
for (int i=1; i<out.length()-1; ) {
if (out.at(i).isSpace() && !(out.at(i-1).isLetterOrNumber() && out.at(i+1).isLetterOrNumber()))
for (int i = 1; i < out.length() - 1; ) {
if (out.at(i).isSpace()
&& !(out.at(i-1).isLetterOrNumber()
&& out.at(i+1).isLetterOrNumber()))
out.remove(i,1);
else
i++;
@@ -650,11 +659,16 @@ void tst_Preprocessor::comparisons_data()
QTest::addColumn<QString>("errorfile");
QTest::newRow("do nothing") << "noPP.1.cpp" << "noPP.1.cpp" << "";
QTest::newRow("identifier-expansion 1") << "identifier-expansion.1.cpp" << "identifier-expansion.1.out.cpp" << "";
QTest::newRow("identifier-expansion 2") << "identifier-expansion.2.cpp" << "identifier-expansion.2.out.cpp" << "";
QTest::newRow("identifier-expansion 3") << "identifier-expansion.3.cpp" << "identifier-expansion.3.out.cpp" << "";
QTest::newRow("identifier-expansion 4") << "identifier-expansion.4.cpp" << "identifier-expansion.4.out.cpp" << "";
QTest::newRow("identifier-expansion 5") << "identifier-expansion.5.cpp" << "identifier-expansion.5.out.cpp" << "";
QTest::newRow("identifier-expansion 1")
<< "identifier-expansion.1.cpp" << "identifier-expansion.1.out.cpp" << "";
QTest::newRow("identifier-expansion 2")
<< "identifier-expansion.2.cpp" << "identifier-expansion.2.out.cpp" << "";
QTest::newRow("identifier-expansion 3")
<< "identifier-expansion.3.cpp" << "identifier-expansion.3.out.cpp" << "";
QTest::newRow("identifier-expansion 4")
<< "identifier-expansion.4.cpp" << "identifier-expansion.4.out.cpp" << "";
QTest::newRow("identifier-expansion 5")
<< "identifier-expansion.5.cpp" << "identifier-expansion.5.out.cpp" << "";
QTest::newRow("reserved 1") << "reserved.1.cpp" << "reserved.1.out.cpp" << "";
QTest::newRow("recursive 1") << "recursive.1.cpp" << "recursive.1.out.cpp" << "";
QTest::newRow("macro_pounder_fn") << "macro_pounder_fn.c" << "" << "";