Commit f4e875b9 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Initial testing of the preprocessor.

parent fd22788d
......@@ -481,6 +481,21 @@ void Preprocessor::popState()
_savedStates.removeLast();
}
QByteArray Preprocessor::operator()(const QByteArray &filename,
const QByteArray &source)
{
QByteArray preprocessed;
operator()(filename, source, &preprocessed);
return preprocessed;
}
QByteArray Preprocessor::operator()(const QByteArray &source)
{
QByteArray preprocessed;
operator()(source, &preprocessed);
return preprocessed;
}
void Preprocessor::operator () (const QByteArray &filename,
const QByteArray &source,
QByteArray *result)
......
......@@ -181,6 +181,11 @@ namespace CPlusPlus {
public:
Preprocessor(Client *client, Environment &env);
QByteArray operator()(const QByteArray &filename,
const QByteArray &source);
QByteArray operator()(const QByteArray &source);
void operator()(const QByteArray &filename,
const QByteArray &source,
QByteArray *result);
......
TEMPLATE = subdirs
SUBDIRS = shared ast semantic lookup
SUBDIRS = shared ast semantic lookup preprocessor
CONFIG += ordered
TEMPLATE = app
CONFIG += qt warn_on console depend_includepath
QT = core testlib
TARGET = tst_$$TARGET
DEFINES += CPLUSPLUS_WITH_NAMESPACE
include(../../../../src/libs/cplusplus/cplusplus-lib.pri)
SOURCES += tst_preprocessor.cpp
#include <QtTest>
#include <pp.h>
CPLUSPLUS_USE_NAMESPACE
class tst_Preprocessor: public QObject
{
Q_OBJECT
private Q_SLOTS:
void pp_with_no_client();
};
void tst_Preprocessor::pp_with_no_client()
{
using namespace CPlusPlus;
Client *client = 0; // no client.
Environment env;
Preprocessor preprocess(client, env);
QByteArray preprocessed = preprocess("#define foo(a,b) a + b\nfoo(1, 2)\n");
QByteArray expected = "1 + 2";
QCOMPARE(preprocessed.trimmed(), expected);
}
QTEST_APPLESS_MAIN(tst_Preprocessor)
#include "tst_preprocessor.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment