diff options
author | Hugo Lima <hugo.lima@openbossa.org> | 2010-03-03 11:15:53 -0300 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2010-03-03 17:34:39 -0300 |
commit | 84b8b4a5b7581c4076bfbf1a19a324cb0561baae (patch) | |
tree | 5d698234fe4b9b99a0dfb1da75b6dae90650e0f0 /tests | |
parent | 62dfdd85bbcac527be99183cfc8e8f7b92902f11 (diff) |
Remove Boost::graph dependence from ApiExtractor by using our own code
for graph topological sort.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/testabstractmetaclass.cpp | 3 | ||||
-rw-r--r-- | tests/testtoposort.cpp | 65 | ||||
-rw-r--r-- | tests/testtoposort.h | 37 |
4 files changed, 106 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 71efb9e90..10cce3fc7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,3 +22,4 @@ declare_test(testmultipleinheritance) declare_test(testrefcounttag) declare_test(testremoveimplconv) declare_test(testreverseoperators) +declare_test(testtoposort) diff --git a/tests/testabstractmetaclass.cpp b/tests/testabstractmetaclass.cpp index 19f383c88..244caa0c4 100644 --- a/tests/testabstractmetaclass.cpp +++ b/tests/testabstractmetaclass.cpp @@ -47,6 +47,9 @@ void TestAbstractMetaClass::testClassNameUnderNamespace() TestUtil t(cppCode, xmlCode); AbstractMetaClassList classes = t.builder()->classes(); QCOMPARE(classes.count(), 2); // 1 namespace + 1 class + if (classes.first()->name() != "ClassName") + classes.swap(0, 1); + QCOMPARE(classes[0]->name(), QString("ClassName")); QCOMPARE(classes[0]->qualifiedCppName(), QString("Namespace::ClassName")); QCOMPARE(classes[1]->name(), QString("Namespace")); diff --git a/tests/testtoposort.cpp b/tests/testtoposort.cpp new file mode 100644 index 000000000..d33786720 --- /dev/null +++ b/tests/testtoposort.cpp @@ -0,0 +1,65 @@ +/* +* This file is part of the API Extractor project. +* +* Copyright (C) 2010 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 "testtoposort.h" +#include <QtTest/QTest> +#include "graph.h" +#include <QDebug> + +void TestTopoSort::testTopoSort() +{ + QLinkedList<int> result; + { + Graph g(3); + g.addEdge(1, 2); + g.addEdge(0, 1); + result = g.topologicalSort(); + QCOMPARE(result.size(), 3); + QLinkedList<int>::iterator it = result.begin(); + QCOMPARE(*it, 0); + QCOMPARE(*(++it), 1); + QCOMPARE(*(++it), 2); + } + { + Graph g(2); + result = g.topologicalSort(); + QCOMPARE(result.size(), 2); + QLinkedList<int>::iterator it = result.begin(); + QCOMPARE(*it, 1); + QCOMPARE(*(++it), 0); + } +} + +void TestTopoSort::testCiclicGraph() +{ + Graph g(3); + g.addEdge(0, 1); + g.addEdge(1, 2); + g.addEdge(2, 0); + QLinkedList<int> result = g.topologicalSort(); + QVERIFY(result.isEmpty()); +} + +QTEST_APPLESS_MAIN(TestTopoSort) + +#include "testtoposort.moc" diff --git a/tests/testtoposort.h b/tests/testtoposort.h new file mode 100644 index 000000000..ad6447abd --- /dev/null +++ b/tests/testtoposort.h @@ -0,0 +1,37 @@ +/* +* This file is part of the API Extractor project. +* +* Copyright (C) 2010 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 TESTTOPOSORT_H +#define TESTTOPOSORT_H + +#include <QObject> + +class TestTopoSort : public QObject +{ +Q_OBJECT +private slots: + void testTopoSort(); + void testCiclicGraph(); +}; + +#endif |