summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor/cppdoxygen_test.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2016-03-04 12:43:06 +0100
committerNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2016-03-04 14:22:27 +0000
commit2b2ba298f3cfc17b74ddd476613377f0b325955b (patch)
tree3ccd65e272d234c0c2b71954884b36776c101d7e /src/plugins/cppeditor/cppdoxygen_test.cpp
parentf99f5dcdc6f1ae26145242712985ca42d724e34d (diff)
downloadqt-creator-2b2ba298f3cfc17b74ddd476613377f0b325955b.tar.gz
CppEditor: Generate doxygen comments for functions with macros
...at least for object-like macros. This handles the common case where a macro before the function signature annotates the DLL import/export. Task-number: QTCREATORBUG-15819 Change-Id: I79f22508188019402fb7345222408aaf90106f20 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'src/plugins/cppeditor/cppdoxygen_test.cpp')
-rw-r--r--src/plugins/cppeditor/cppdoxygen_test.cpp41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/plugins/cppeditor/cppdoxygen_test.cpp b/src/plugins/cppeditor/cppdoxygen_test.cpp
index 91b2207b40..ebbb109af3 100644
--- a/src/plugins/cppeditor/cppdoxygen_test.cpp
+++ b/src/plugins/cppeditor/cppdoxygen_test.cpp
@@ -281,6 +281,18 @@ void DoxygenTest::testBasic_data()
"*foo /*\n"
" \n"
);
+
+ QTest::newRow("withMacroFromDocumentBeforeFunction") << _(
+ "#define API\n"
+ "/**|\n"
+ "API void f();\n"
+ ) << _(
+ "#define API\n"
+ "/**\n"
+ " * @brief f\n"
+ " */\n"
+ "API void f();\n"
+ );
}
void DoxygenTest::testBasic()
@@ -290,6 +302,25 @@ void DoxygenTest::testBasic()
runTest(given, expected);
}
+void DoxygenTest::testWithMacroFromHeaderBeforeFunction()
+{
+ const QByteArray given =
+ "#include \"header.h\"\n"
+ "/**|\n"
+ "API void f();\n";
+
+ const QByteArray expected =
+ "#include \"header.h\"\n"
+ "/**\n"
+ " * @brief f\n"
+ " */\n"
+ "API void f();\n";
+
+ const TestDocument headerDocumentDefiningMacro("header.h", "#define API\n");
+
+ runTest(given, expected, /*settings=*/ 0, { headerDocumentDefiningMacro });
+}
+
void DoxygenTest::testNoLeadingAsterisks_data()
{
QTest::addColumn<QByteArray>("given");
@@ -323,8 +354,10 @@ void DoxygenTest::verifyCleanState() const
}
/// The '|' in the input denotes the cursor position.
-void DoxygenTest::runTest(const QByteArray &original, const QByteArray &expected,
- CppTools::CommentsSettings *settings)
+void DoxygenTest::runTest(const QByteArray &original,
+ const QByteArray &expected,
+ CppTools::CommentsSettings *settings,
+ const TestDocuments &includedHeaderDocuments)
{
// Write files to disk
CppTools::Tests::TemporaryDir temporaryDir;
@@ -334,6 +367,10 @@ void DoxygenTest::runTest(const QByteArray &original, const QByteArray &expected
testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
testDocument.setBaseDirectory(temporaryDir.path());
QVERIFY(testDocument.writeToDisk());
+ foreach (TestDocument testDocument, includedHeaderDocuments) {
+ testDocument.setBaseDirectory(temporaryDir.path());
+ QVERIFY(testDocument.writeToDisk());
+ }
// Update Code Model
QVERIFY(TestCase::parseFiles(testDocument.filePath()));