tests: Remove foreach usage

Task-number: QTCREATORBUG-27464
Change-Id: I0e42da9b04793be959ad050fdecc0c78c98d9fcd
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Artem Sokolovskii
2022-12-21 13:05:34 +01:00
parent cead76f378
commit a5bee6e3ae
19 changed files with 115 additions and 92 deletions

View File

@@ -152,23 +152,23 @@ struct Line {
int expectedPadding;
};
QString concatLines(QList<Line> lines)
QString concatLines(const QList<Line> &lines)
{
QString result;
foreach (const Line &l, lines) {
for (const Line &l : lines) {
result += l.line;
result += "\n";
}
return result;
}
void checkIndent(QList<Line> data, QtStyleCodeFormatter formatter)
void checkIndent(const QList<Line> &data, QtStyleCodeFormatter formatter)
{
QString text = concatLines(data);
QTextDocument document(text);
int i = 0;
foreach (const Line &l, data) {
for (const Line &l : data) {
QTextBlock b = document.findBlockByLineNumber(i);
if (l.expectedIndent != -1) {
int indent, padding;
@@ -183,14 +183,14 @@ void checkIndent(QList<Line> data, QtStyleCodeFormatter formatter)
}
}
void checkIndent(QList<Line> data, CppCodeStyleSettings style)
void checkIndent(QList<Line> &data, CppCodeStyleSettings style)
{
QtStyleCodeFormatter formatter;
formatter.setCodeStyleSettings(style);
checkIndent(data, formatter);
}
void checkIndent(QList<Line> data, int style = 0)
void checkIndent(QList<Line> &data, int style = 0)
{
CppCodeStyleSettings codeStyle;
QtStyleCodeFormatter formatter;