aboutsummaryrefslogtreecommitdiffstats
path: root/tests/testmodifydocumentation.cpp
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2009-09-23 17:14:23 -0300
committerHugo Lima <hugo.lima@openbossa.org>2009-09-24 17:27:12 -0300
commit9a34c9489429c17a36d248da91be10ca0f927d26 (patch)
tree027d36f5246c832a7f54539973ff26fb866e06a4 /tests/testmodifydocumentation.cpp
parent5604a7b2f41fda5d78271032429805604b6f08c3 (diff)
Unit test to catch the bug#38.
Diffstat (limited to 'tests/testmodifydocumentation.cpp')
-rw-r--r--tests/testmodifydocumentation.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/testmodifydocumentation.cpp b/tests/testmodifydocumentation.cpp
new file mode 100644
index 000000000..5a9e2c386
--- /dev/null
+++ b/tests/testmodifydocumentation.cpp
@@ -0,0 +1,66 @@
+/*
+* This file is part of the API Extractor project.
+*
+* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+*
+* Contact: PySide team <contact@pyside.org>
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* version 2 as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+*
+*/
+
+#include "testmodifydocumentation.h"
+
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <qtdocparser.h>
+
+void TestModifyDocumentation::testModifyDocumentation()
+{
+ const char* cppCode ="struct B { void b(); }; class A {};";
+ const char* xmlCode = "<typesystem package=\"Foo\">\
+ <value-type name='B'>\
+ <modify-function signature='b()' remove='all' />\
+ </value-type>\
+ <value-type name='A'>\
+ <modify-documentation xpath='description/para[3]'>\
+ &lt;para>Some changed contents here&lt;/para>\
+ </modify-documentation>\
+ </value-type>\
+ </typesystem>";
+ TestUtil t(cppCode, xmlCode);
+
+ AbstractMetaClass* classA = t.builder()->classes().findClass("A");
+ QVERIFY(classA);
+ DocModificationList docMods = classA->typeEntry()->docModifications();
+ QCOMPARE(docMods.count(), 1);
+ QCOMPARE(docMods[0].code().trimmed(), QString("<para>Some changed contents here</para>"));
+ QCOMPARE(docMods[0].signature(), QString(""));
+ QtDocParser docParser;
+ docParser.setDocumentationDataDirectory(QFileInfo(__FILE__).absoluteDir().absolutePath());
+ docParser.fillDocumentation(classA);
+
+ QVERIFY(!classA->documentation().value().trimmed().isEmpty());
+ QCOMPARE(classA->documentation().value(), QString("<?xml version=\"1.0\"?>\n\
+<description>oi\n\
+ <para>Paragraph number 1</para>\n\
+ <para>Paragraph number 2</para>\n\
+ <para>Some changed contents here</para>\n\
+</description>\n"));
+}
+
+QTEST_MAIN(TestModifyDocumentation)
+
+#include "testmodifydocumentation.moc"