forked from qt-creator/qt-creator
Sprinkled a bit of doxymentation over various classes.
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
#include <QtDebug>
|
||||
#include <QTextDocument>
|
||||
|
||||
/*!
|
||||
Tests for various parts of the code generation. Well, okay, currently it only
|
||||
tests the InsertionPointLocator.
|
||||
*/
|
||||
using namespace CPlusPlus;
|
||||
|
||||
class tst_Codegen: public QObject
|
||||
@@ -29,6 +33,44 @@ private slots:
|
||||
void qtdesigner_integration();
|
||||
};
|
||||
|
||||
/*!
|
||||
Should insert at line 3, column 1, with "public:\n" as prefix and without suffix.
|
||||
*/
|
||||
void tst_Codegen::public_in_empty_class()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
"class Foo\n" // line 1
|
||||
"{\n"
|
||||
"};\n"
|
||||
"\n";
|
||||
|
||||
Document::Ptr doc = Document::create("public_in_empty_class");
|
||||
doc->setSource(src);
|
||||
doc->parse();
|
||||
doc->check();
|
||||
|
||||
QCOMPARE(doc->diagnosticMessages().size(), 0);
|
||||
QCOMPARE(doc->globalSymbolCount(), 1U);
|
||||
|
||||
Class *mainWindow = doc->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(mainWindow);
|
||||
QCOMPARE(mainWindow->line(), 1U);
|
||||
QCOMPARE(mainWindow->column(), 7U);
|
||||
|
||||
InsertionPointLocator find(doc);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
mainWindow,
|
||||
InsertionPointLocator::Public);
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("public:\n"));
|
||||
QVERIFY(loc.suffix().isEmpty());
|
||||
QCOMPARE(loc.line(), 3U);
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
}
|
||||
|
||||
/*!
|
||||
Should insert at line 3, column 1, without prefix and without suffix.
|
||||
*/
|
||||
void tst_Codegen::public_in_nonempty_class()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
@@ -52,7 +94,9 @@ void tst_Codegen::public_in_nonempty_class()
|
||||
QCOMPARE(mainWindow->column(), 7U);
|
||||
|
||||
InsertionPointLocator find(doc);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(mainWindow, InsertionPointLocator::Public);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
mainWindow,
|
||||
InsertionPointLocator::Public);
|
||||
QVERIFY(loc.isValid());
|
||||
QVERIFY(loc.prefix().isEmpty());
|
||||
QVERIFY(loc.suffix().isEmpty());
|
||||
@@ -60,36 +104,9 @@ void tst_Codegen::public_in_nonempty_class()
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
}
|
||||
|
||||
void tst_Codegen::public_in_empty_class()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
"class Foo\n" // line 1
|
||||
"{\n"
|
||||
"};\n"
|
||||
"\n";
|
||||
|
||||
Document::Ptr doc = Document::create("public_in_empty_class");
|
||||
doc->setSource(src);
|
||||
doc->parse();
|
||||
doc->check();
|
||||
|
||||
QCOMPARE(doc->diagnosticMessages().size(), 0);
|
||||
QCOMPARE(doc->globalSymbolCount(), 1U);
|
||||
|
||||
Class *mainWindow = doc->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(mainWindow);
|
||||
QCOMPARE(mainWindow->line(), 1U);
|
||||
QCOMPARE(mainWindow->column(), 7U);
|
||||
|
||||
InsertionPointLocator find(doc);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(mainWindow, InsertionPointLocator::Public);
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("public:\n"));
|
||||
QVERIFY(loc.suffix().isEmpty());
|
||||
QCOMPARE(loc.line(), 3U);
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
}
|
||||
|
||||
/*!
|
||||
Should insert at line 3, column 1, with "public:\n" as prefix and "\n suffix.
|
||||
*/
|
||||
void tst_Codegen::public_before_protected()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
@@ -113,7 +130,9 @@ void tst_Codegen::public_before_protected()
|
||||
QCOMPARE(mainWindow->column(), 7U);
|
||||
|
||||
InsertionPointLocator find(doc);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(mainWindow, InsertionPointLocator::Public);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
mainWindow,
|
||||
InsertionPointLocator::Public);
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("public:\n"));
|
||||
QCOMPARE(loc.suffix(), QLatin1String("\n"));
|
||||
@@ -121,6 +140,10 @@ void tst_Codegen::public_before_protected()
|
||||
QCOMPARE(loc.line(), 3U);
|
||||
}
|
||||
|
||||
/*!
|
||||
Should insert at line 4, column 1, with "private:\n" as prefix and without
|
||||
suffix.
|
||||
*/
|
||||
void tst_Codegen::private_after_protected()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
@@ -144,7 +167,9 @@ void tst_Codegen::private_after_protected()
|
||||
QCOMPARE(mainWindow->column(), 7U);
|
||||
|
||||
InsertionPointLocator find(doc);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(mainWindow, InsertionPointLocator::Private);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
mainWindow,
|
||||
InsertionPointLocator::Private);
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("private:\n"));
|
||||
QVERIFY(loc.suffix().isEmpty());
|
||||
@@ -152,6 +177,10 @@ void tst_Codegen::private_after_protected()
|
||||
QCOMPARE(loc.line(), 4U);
|
||||
}
|
||||
|
||||
/*!
|
||||
Should insert at line 4, column 1, with "protected:\n" as prefix and without
|
||||
suffix.
|
||||
*/
|
||||
void tst_Codegen::protected_in_nonempty_class()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
@@ -175,7 +204,9 @@ void tst_Codegen::protected_in_nonempty_class()
|
||||
QCOMPARE(mainWindow->column(), 7U);
|
||||
|
||||
InsertionPointLocator find(doc);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(mainWindow, InsertionPointLocator::Protected);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
mainWindow,
|
||||
InsertionPointLocator::Protected);
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("protected:\n"));
|
||||
QVERIFY(loc.suffix().isEmpty());
|
||||
@@ -183,6 +214,9 @@ void tst_Codegen::protected_in_nonempty_class()
|
||||
QCOMPARE(loc.line(), 4U);
|
||||
}
|
||||
|
||||
/*!
|
||||
Should insert at line 4, column 1, with "protected\n" as prefix and "\n" suffix.
|
||||
*/
|
||||
void tst_Codegen::protected_betwee_public_and_private()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
@@ -207,7 +241,9 @@ void tst_Codegen::protected_betwee_public_and_private()
|
||||
QCOMPARE(mainWindow->column(), 7U);
|
||||
|
||||
InsertionPointLocator find(doc);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(mainWindow, InsertionPointLocator::Protected);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
mainWindow,
|
||||
InsertionPointLocator::Protected);
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("protected:\n"));
|
||||
QCOMPARE(loc.suffix(), QLatin1String("\n"));
|
||||
@@ -215,6 +251,13 @@ void tst_Codegen::protected_betwee_public_and_private()
|
||||
QCOMPARE(loc.line(), 4U);
|
||||
}
|
||||
|
||||
/*!
|
||||
Should insert at line 18, column 1, with "private slots:\n" as prefix and "\n"
|
||||
as suffix.
|
||||
|
||||
This is the typical Qt Designer case, with test-input like what the integration
|
||||
generates.
|
||||
*/
|
||||
void tst_Codegen::qtdesigner_integration()
|
||||
{
|
||||
const QByteArray src = "/**** Some long (C)opyright notice ****/\n"
|
||||
@@ -255,7 +298,9 @@ void tst_Codegen::qtdesigner_integration()
|
||||
QCOMPARE(mainWindow->column(), 7U);
|
||||
|
||||
InsertionPointLocator find(doc);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(mainWindow, InsertionPointLocator::PrivateSlot);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
mainWindow,
|
||||
InsertionPointLocator::PrivateSlot);
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("private slots:\n"));
|
||||
QCOMPARE(loc.suffix(), QLatin1String("\n"));
|
||||
|
||||
Reference in New Issue
Block a user