aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/tests/testtoposort.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-13 14:05:04 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-27 09:04:18 +0000
commit5b87b64f6a6a2404d01f24b2c5a2189e406bddf8 (patch)
tree37a06a6df8276884b860dbc63d233b8b829c0283 /sources/shiboken2/ApiExtractor/tests/testtoposort.cpp
parent636b9a4bd5624d8ddb00da53b16add546e3944c4 (diff)
shiboken2: Improve error messages about cyclic dependencies
Return a struct instead of a plain list from Graph::topologicalSort() which contains the offending indexes and output the elements in case of failure. Task-number: PYSIDE-1202 Change-Id: Ib7f70c78be0e84272f31d802677c7fc333aa32f4 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/tests/testtoposort.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testtoposort.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/sources/shiboken2/ApiExtractor/tests/testtoposort.cpp b/sources/shiboken2/ApiExtractor/tests/testtoposort.cpp
index c59fa8c3d..25eb99e50 100644
--- a/sources/shiboken2/ApiExtractor/tests/testtoposort.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testtoposort.cpp
@@ -38,8 +38,10 @@ void TestTopoSort::testTopoSort()
g.addEdge(1, 2);
g.addEdge(0, 1);
const auto result = g.topologicalSort();
- QCOMPARE(result.size(), 3);
- auto it = result.begin();
+ QVERIFY(result.isValid());
+ QVERIFY(result.cyclic.isEmpty());
+ QCOMPARE(result.result.size(), 3);
+ auto it = result.result.begin();
QCOMPARE(*it, 0);
QCOMPARE(*(++it), 1);
QCOMPARE(*(++it), 2);
@@ -47,21 +49,25 @@ void TestTopoSort::testTopoSort()
{
Graph g(2);
const auto result = g.topologicalSort();
- QCOMPARE(result.size(), 2);
- auto it = result.begin();
+ QVERIFY(result.isValid());
+ QVERIFY(result.cyclic.isEmpty());
+ QCOMPARE(result.result.size(), 2);
+ auto it = result.result.begin();
QCOMPARE(*it, 1);
QCOMPARE(*(++it), 0);
}
}
-void TestTopoSort::testCiclicGraph()
+void TestTopoSort::testCyclicGraph()
{
Graph g(3);
g.addEdge(0, 1);
g.addEdge(1, 2);
g.addEdge(2, 0);
const auto result = g.topologicalSort();
- QVERIFY(result.isEmpty());
+ QVERIFY(!result.isValid());
+ QVERIFY(result.result.isEmpty());
+ QVERIFY(!result.cyclic.isEmpty());
}
QTEST_APPLESS_MAIN(TestTopoSort)