forked from qt-creator/qt-creator
preprocessor: some code style in auto test
Change-Id: I1381ce17098a87dbc3924dc86902d7cc1b1eec76 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -75,20 +75,23 @@ struct Include
|
|||||||
Client::IncludeType type;
|
Client::IncludeType type;
|
||||||
unsigned line;
|
unsigned line;
|
||||||
};
|
};
|
||||||
QDebug &operator<<(QDebug& d, const Include &i) {
|
|
||||||
|
QDebug &operator<<(QDebug& d, const Include &i)
|
||||||
|
{
|
||||||
d << '[' << i.fileName
|
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
|
<< ',' << i.line
|
||||||
<< ']';
|
<< ']';
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockClient: public Client
|
class MockClient : public Client
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct Block {
|
struct Block {
|
||||||
Block(): start(0), end(0) {}
|
Block() : start(0), end(0) {}
|
||||||
Block(unsigned start): start(start), end(0) {}
|
Block(unsigned start) : start(start), end(0) {}
|
||||||
|
|
||||||
unsigned start;
|
unsigned start;
|
||||||
unsigned end;
|
unsigned end;
|
||||||
@@ -123,8 +126,7 @@ public:
|
|||||||
m_expandedMacrosOffset.append(offset);
|
m_expandedMacrosOffset.append(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void stopExpandingMacro(unsigned /*offset*/,
|
virtual void stopExpandingMacro(unsigned /*offset*/, const Macro &/*macro*/) {}
|
||||||
const Macro &/*macro*/) {}
|
|
||||||
|
|
||||||
virtual void startSkippingBlocks(unsigned offset)
|
virtual void startSkippingBlocks(unsigned offset)
|
||||||
{ m_skippedBlocks.append(Block(offset)); }
|
{ m_skippedBlocks.append(Block(offset)); }
|
||||||
@@ -266,9 +268,13 @@ namespace QTest {
|
|||||||
}
|
}
|
||||||
QT_END_NAMESPACE
|
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
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -318,15 +324,18 @@ QString tst_Preprocessor::simplified(QByteArray buf)
|
|||||||
{
|
{
|
||||||
QString out;
|
QString out;
|
||||||
QList<QByteArray> lines = buf.split('\n');
|
QList<QByteArray> lines = buf.split('\n');
|
||||||
foreach (QByteArray line, lines)
|
foreach (const QByteArray &line, lines) {
|
||||||
if (!line.startsWith('#')) {
|
if (!line.startsWith('#')) {
|
||||||
out.append(' ');
|
out.append(' ');
|
||||||
out.append(line);
|
out.append(line);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out = out.simplified();
|
out = out.simplified();
|
||||||
for (int i=1; i<out.length()-1; ) {
|
for (int i = 1; i < out.length() - 1; ) {
|
||||||
if (out.at(i).isSpace() && !(out.at(i-1).isLetterOrNumber() && out.at(i+1).isLetterOrNumber()))
|
if (out.at(i).isSpace()
|
||||||
|
&& !(out.at(i-1).isLetterOrNumber()
|
||||||
|
&& out.at(i+1).isLetterOrNumber()))
|
||||||
out.remove(i,1);
|
out.remove(i,1);
|
||||||
else
|
else
|
||||||
i++;
|
i++;
|
||||||
@@ -650,11 +659,16 @@ void tst_Preprocessor::comparisons_data()
|
|||||||
QTest::addColumn<QString>("errorfile");
|
QTest::addColumn<QString>("errorfile");
|
||||||
|
|
||||||
QTest::newRow("do nothing") << "noPP.1.cpp" << "noPP.1.cpp" << "";
|
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 1")
|
||||||
QTest::newRow("identifier-expansion 2") << "identifier-expansion.2.cpp" << "identifier-expansion.2.out.cpp" << "";
|
<< "identifier-expansion.1.cpp" << "identifier-expansion.1.out.cpp" << "";
|
||||||
QTest::newRow("identifier-expansion 3") << "identifier-expansion.3.cpp" << "identifier-expansion.3.out.cpp" << "";
|
QTest::newRow("identifier-expansion 2")
|
||||||
QTest::newRow("identifier-expansion 4") << "identifier-expansion.4.cpp" << "identifier-expansion.4.out.cpp" << "";
|
<< "identifier-expansion.2.cpp" << "identifier-expansion.2.out.cpp" << "";
|
||||||
QTest::newRow("identifier-expansion 5") << "identifier-expansion.5.cpp" << "identifier-expansion.5.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("reserved 1") << "reserved.1.cpp" << "reserved.1.out.cpp" << "";
|
||||||
QTest::newRow("recursive 1") << "recursive.1.cpp" << "recursive.1.out.cpp" << "";
|
QTest::newRow("recursive 1") << "recursive.1.cpp" << "recursive.1.out.cpp" << "";
|
||||||
QTest::newRow("macro_pounder_fn") << "macro_pounder_fn.c" << "" << "";
|
QTest::newRow("macro_pounder_fn") << "macro_pounder_fn.c" << "" << "";
|
||||||
|
|||||||
Reference in New Issue
Block a user