Commit 6d00ff37 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Added tests for the DiagnosticClient.

parent b54e976f
...@@ -10,5 +10,6 @@ SUBDIRS = \ ...@@ -10,5 +10,6 @@ SUBDIRS = \
preprocessor \ preprocessor \
semantic \ semantic \
typeprettyprinter \ typeprettyprinter \
simplifytypes simplifytypes \
misc
include(../../qttest.pri)
include(../shared/shared.pri)
INCLUDEPATH += $$IDE_SOURCE_TREE/src/plugins
SOURCES += tst_misc.cpp
#include <CppDocument.h>
#include <QtTest>
#include <QtDebug>
using namespace CPlusPlus;
class tst_Misc: public QObject
{
Q_OBJECT
private slots:
void diagnosticClient_error();
void diagnosticClient_warning();
};
void tst_Misc::diagnosticClient_error()
{
const QByteArray src("\n"
"class Foo {}\n"
);
Document::Ptr doc = Document::create("diagnosticClient_error");
QVERIFY(!doc.isNull());
doc->setSource(src);
bool success = doc->parse(Document::ParseTranlationUnit);
QVERIFY(success);
QList<Document::DiagnosticMessage> diagnostics = doc->diagnosticMessages();
QVERIFY(diagnostics.size() == 1);
const Document::DiagnosticMessage &msg = diagnostics.at(0);
QCOMPARE(msg.level(), (int) Document::DiagnosticMessage::Error);
QCOMPARE(msg.line(), 2U);
QCOMPARE(msg.column(), 1U);
}
void tst_Misc::diagnosticClient_warning()
{
const QByteArray src("\n"
"using namespace ;\n"
);
Document::Ptr doc = Document::create("diagnosticClient_warning");
QVERIFY(!doc.isNull());
doc->setSource(src);
bool success = doc->parse(Document::ParseTranlationUnit);
QVERIFY(success);
QList<Document::DiagnosticMessage> diagnostics = doc->diagnosticMessages();
QVERIFY(diagnostics.size() == 1);
const Document::DiagnosticMessage &msg = diagnostics.at(0);
QCOMPARE(msg.level(), (int) Document::DiagnosticMessage::Warning);
QCOMPARE(msg.line(), 1U);
QCOMPARE(msg.column(), 17U);
}
QTEST_MAIN(tst_Misc)
#include "tst_misc.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