C++: Add a failing test for pp concat bug

Task-number: QTCREATORBUG-13219
Change-Id: I6278d7977f0ce560e793838c90cfbc867e1af025
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2014-10-22 10:51:07 +03:00
committed by Orgad Shaneh
parent b4112d7806
commit e871225057

View File

@@ -389,6 +389,7 @@ private slots:
void empty_trailing_lines();
void empty_trailing_lines_data();
void undef();
void concat();
};
// Remove all #... lines, and 'simplify' string, to allow easily comparing the result
@@ -1868,6 +1869,32 @@ void tst_Preprocessor::undef()
QVERIFY(client.macroUsesLine()["BAR"].isEmpty());
}
void tst_Preprocessor::concat()
{
Environment env;
Preprocessor preprocess(0, &env);
QByteArray input =
"#define concat(x,y) x ## y\n"
"#define xconcat(x, y) concat(x, y)\n"
"#define FOO 42\n"
"int var = xconcat(0x, FOO);\n";
QByteArray prep = preprocess.run(QLatin1String("<stdin>"), input);
const QByteArray output = _(
"# 1 \"<stdin>\"\n"
"\n"
"\n"
"\n"
"int var =\n"
"# expansion begin 87,7 ~1\n"
"0x42\n"
"# expansion end\n"
"# 4 \"<stdin>\"\n"
" ;\n"
);
QEXPECT_FAIL(0, "QTCREATORBUG-13219", Abort);
QCOMPARE(prep.constData(), output.constData());
}
void tst_Preprocessor::compare_input_output(bool keepComments)
{
QFETCH(QByteArray, input);