diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-11-24 10:19:10 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-11-24 10:19:10 -0300 |
commit | 6d8dea54288cf7864c602b826b5be90b4a0b95f6 (patch) | |
tree | 54984c56807b15fad39b8e372699faa781b07188 /tests | |
parent | 49610841579e8a7ef614477a0e73c78502c2afc9 (diff) |
Added methods to set and check for protected and virtual destructor
on AbstractMetaClass objects. Also added tests for this.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/testdtorinformation.cpp | 76 | ||||
-rw-r--r-- | tests/testdtorinformation.h | 41 |
3 files changed, 118 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5a104907d..78966362c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,3 +14,4 @@ declare_test(testmodifydocumentation) declare_test(testaddfunction) declare_test(testconversionruletag) declare_test(testreverseoperators) +declare_test(testdtorinformation) diff --git a/tests/testdtorinformation.cpp b/tests/testdtorinformation.cpp new file mode 100644 index 000000000..1aaeb91dc --- /dev/null +++ b/tests/testdtorinformation.cpp @@ -0,0 +1,76 @@ +/* +* 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 "testdtorinformation.h" +#include "abstractmetabuilder.h" +#include <QtTest/QTest> +#include "testutil.h" + +void TestDtorInformation::testDtorIsPrivate() +{ + const char* cppCode ="class Control { public: ~Control() {} }; class Subject { private: ~Subject() {} };"; + const char* xmlCode = "<typesystem package=\"Foo\"><value-type name=\"Control\"/><value-type name=\"Subject\"/></typesystem>"; + TestUtil t(cppCode, xmlCode); + AbstractMetaClassList classes = t.builder()->classes(); + QCOMPARE(classes.count(), 2); + QCOMPARE(classes.findClass("Control")->hasPrivateDestructor(), false); + QCOMPARE(classes.findClass("Subject")->hasPrivateDestructor(), true); +} + +void TestDtorInformation::testDtorIsProtected() +{ + const char* cppCode ="class Control { public: ~Control() {} }; class Subject { protected: ~Subject() {} };"; + const char* xmlCode = "<typesystem package=\"Foo\"><value-type name=\"Control\"/><value-type name=\"Subject\"/></typesystem>"; + TestUtil t(cppCode, xmlCode); + AbstractMetaClassList classes = t.builder()->classes(); + QCOMPARE(classes.count(), 2); + QCOMPARE(classes.findClass("Control")->hasProtectedDestructor(), false); + QCOMPARE(classes.findClass("Subject")->hasProtectedDestructor(), true); +} + +void TestDtorInformation::testDtorIsVirtual() +{ + const char* cppCode ="class Control { public: ~Control() {} }; class Subject { protected: virtual ~Subject() {} };"; + const char* xmlCode = "<typesystem package=\"Foo\"><value-type name=\"Control\"/><value-type name=\"Subject\"/></typesystem>"; + TestUtil t(cppCode, xmlCode); + AbstractMetaClassList classes = t.builder()->classes(); + QCOMPARE(classes.count(), 2); + QCOMPARE(classes.findClass("Control")->hasVirtualDestructor(), false); + QCOMPARE(classes.findClass("Subject")->hasVirtualDestructor(), true); +} + +void TestDtorInformation::testClassWithVirtualDtorIsPolymorphic() +{ + const char* cppCode ="class Control { public: virtual ~Control() {} }; class Subject { protected: virtual ~Subject() {} };"; + const char* xmlCode = "<typesystem package=\"Foo\"><value-type name=\"Control\"/><value-type name=\"Subject\"/></typesystem>"; + TestUtil t(cppCode, xmlCode); + AbstractMetaClassList classes = t.builder()->classes(); + QCOMPARE(classes.count(), 2); + QCOMPARE(classes.findClass("Control")->isPolymorphic(), true); + QCOMPARE(classes.findClass("Subject")->isPolymorphic(), true); +} + +QTEST_APPLESS_MAIN(TestDtorInformation) + +#include "testdtorinformation.moc" + diff --git a/tests/testdtorinformation.h b/tests/testdtorinformation.h new file mode 100644 index 000000000..2e378001b --- /dev/null +++ b/tests/testdtorinformation.h @@ -0,0 +1,41 @@ +/* +* 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 +* +*/ + +#ifndef TESTDTORINFORMATION_H +#define TESTDTORINFORMATION_H + +#include <QObject> + +class AbstractMetaBuilder; + +class TestDtorInformation: public QObject +{ + Q_OBJECT +private slots: + void testDtorIsPrivate(); + void testDtorIsProtected(); + void testDtorIsVirtual(); + void testClassWithVirtualDtorIsPolymorphic(); +}; + +#endif // TESTDTORINFORMATION_H |