diff options
| author | Erik Verbruggen <erik.verbruggen@nokia.com> | 2010-07-28 17:33:21 +0200 |
|---|---|---|
| committer | Erik Verbruggen <erik.verbruggen@nokia.com> | 2010-07-28 17:34:00 +0200 |
| commit | 6bbc732a2911e6f4093bb88ae3132a9d4a33ba43 (patch) | |
| tree | b492c9c56c2e8cf3a93f1ffeb7751da35141bffd /tests/auto/cplusplus/codegen/tst_codegen.cpp | |
| parent | 28be7bc4b49b4afda96fdf16c8a0edeaea991a1d (diff) | |
| download | qt-creator-6bbc732a2911e6f4093bb88ae3132a9d4a33ba43.tar.gz | |
Sprinkled a bit of doxymentation over various classes.
Diffstat (limited to 'tests/auto/cplusplus/codegen/tst_codegen.cpp')
| -rw-r--r-- | tests/auto/cplusplus/codegen/tst_codegen.cpp | 81 |
1 files changed, 63 insertions, 18 deletions
diff --git a/tests/auto/cplusplus/codegen/tst_codegen.cpp b/tests/auto/cplusplus/codegen/tst_codegen.cpp index 60b66b6b97..c53dfad3cd 100644 --- a/tests/auto/cplusplus/codegen/tst_codegen.cpp +++ b/tests/auto/cplusplus/codegen/tst_codegen.cpp @@ -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,16 +33,18 @@ private slots: void qtdesigner_integration(); }; -void tst_Codegen::public_in_nonempty_class() +/*! + 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" - "public:\n" // line 3 - "};\n" // line 4 + "};\n" "\n"; - Document::Ptr doc = Document::create("public_in_nonempty_class"); + Document::Ptr doc = Document::create("public_in_empty_class"); doc->setSource(src); doc->parse(); doc->check(); @@ -52,23 +58,29 @@ 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()); + QCOMPARE(loc.prefix(), QLatin1String("public:\n")); QVERIFY(loc.suffix().isEmpty()); - QCOMPARE(loc.line(), 4U); + QCOMPARE(loc.line(), 3U); QCOMPARE(loc.column(), 1U); } -void tst_Codegen::public_in_empty_class() +/*! + Should insert at line 3, column 1, without prefix and without suffix. + */ +void tst_Codegen::public_in_nonempty_class() { const QByteArray src = "\n" "class Foo\n" // line 1 "{\n" - "};\n" + "public:\n" // line 3 + "};\n" // line 4 "\n"; - Document::Ptr doc = Document::create("public_in_empty_class"); + Document::Ptr doc = Document::create("public_in_nonempty_class"); doc->setSource(src); doc->parse(); doc->check(); @@ -82,14 +94,19 @@ void tst_Codegen::public_in_empty_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()); - QCOMPARE(loc.prefix(), QLatin1String("public:\n")); + QVERIFY(loc.prefix().isEmpty()); QVERIFY(loc.suffix().isEmpty()); - QCOMPARE(loc.line(), 3U); + QCOMPARE(loc.line(), 4U); 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")); |
