C++ indenter: Fix for statement indentation and add test.

This commit is contained in:
Christian Kamm
2010-09-15 10:57:57 +02:00
parent 7167bdddfb
commit e5cbb56fe7
2 changed files with 43 additions and 4 deletions

View File

@@ -47,6 +47,7 @@ private Q_SLOTS:
void streamOp();
void blockStmtInIf();
void nestedInitializer();
void forStatement();
};
struct Line {
@@ -904,6 +905,40 @@ void tst_CodeFormatter::nestedInitializer()
checkIndent(data);
}
void tst_CodeFormatter::forStatement()
{
QList<Line> data;
data
<< Line("void foo()")
<< Line("{")
<< Line(" for (a; b; c)")
<< Line(" bar();")
<< Line(" for (a; b; c) {")
<< Line(" bar();")
<< Line(" }")
<< Line(" for (a; b; c)")
<< Line(" {")
<< Line(" bar();")
<< Line(" }")
<< Line(" for (a;")
<< Line(" ~ b;")
<< Line(" ~ c)")
<< Line(" bar();")
<< Line(" for (a;")
<< Line(" ~ b;")
<< Line(" ~ c) {")
<< Line(" bar();")
<< Line(" }")
<< Line(" for (a;")
<< Line(" ~ b;")
<< Line(" ~ c)")
<< Line(" {")
<< Line(" bar();")
<< Line(" }")
;
checkIndent(data);
}
QTEST_APPLESS_MAIN(tst_CodeFormatter)
#include "tst_codeformatter.moc"