forked from qt-creator/qt-creator
Improved the way we expand function-like macros when we can't collect all the arguments.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include <QtTest>
|
||||
#include <pp.h>
|
||||
|
||||
CPLUSPLUS_USE_NAMESPACE
|
||||
using namespace CPlusPlus;
|
||||
|
||||
class tst_Preprocessor: public QObject
|
||||
{
|
||||
@@ -9,21 +9,35 @@ Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void pp_with_no_client();
|
||||
|
||||
void unfinished_function_like_macro_call();
|
||||
};
|
||||
|
||||
void tst_Preprocessor::pp_with_no_client()
|
||||
{
|
||||
using namespace CPlusPlus;
|
||||
|
||||
Client *client = 0; // no client.
|
||||
Environment env;
|
||||
|
||||
Preprocessor preprocess(client, &env);
|
||||
QByteArray preprocessed = preprocess("<stdin>",
|
||||
"#define foo(a,b) a + b\nfoo(1, 2)\n");
|
||||
"\n#define foo(a,b) a + b"
|
||||
"\nfoo(1, 2)\n");
|
||||
QByteArray expected = "1 + 2";
|
||||
QCOMPARE(preprocessed.trimmed(), expected);
|
||||
}
|
||||
|
||||
void tst_Preprocessor::unfinished_function_like_macro_call()
|
||||
{
|
||||
Client *client = 0; // no client.
|
||||
Environment env;
|
||||
|
||||
Preprocessor preprocess(client, &env);
|
||||
QByteArray preprocessed = preprocess("<stdin>",
|
||||
"\n#define foo(a,b) a + b"
|
||||
"\nfoo(1, 2\n");
|
||||
QByteArray expected = "foo";
|
||||
QCOMPARE(preprocessed.trimmed(), expected);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_Preprocessor)
|
||||
#include "tst_preprocessor.moc"
|
||||
|
||||
Reference in New Issue
Block a user