diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-02-08 13:18:52 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-02-08 14:49:36 +0100 |
commit | db824ef8c01b79a60c8029061eb5c86b51dd87fc (patch) | |
tree | b97b56d434c37fd7b00f1bce836f44174c3e3b07 | |
parent | e2c129373d4bde20382f91d11e51c75702732a43 (diff) |
shiboken6: Add more formatting tests to sphinxtable test
Add a test using programmatically constructed tables.
Change-Id: I81ede76df045e730e27c102576d86a883e141a4e
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r-- | sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.cpp | 67 | ||||
-rw-r--r-- | sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h | 2 |
2 files changed, 69 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.cpp b/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.cpp index 6e47ea688..5bac4d956 100644 --- a/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.cpp +++ b/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.cpp @@ -364,4 +364,71 @@ void QtXmlToSphinxTest::testTable() QCOMPARE(actual, expected); } +using TablePtr = QSharedPointer<QtXmlToSphinx::Table>; + +Q_DECLARE_METATYPE(TablePtr); + +void QtXmlToSphinxTest::testTableFormatting_data() +{ + using TableRow = QtXmlToSphinx::TableRow; + using TableCell = QtXmlToSphinx::TableCell; + + QTest::addColumn<TablePtr>("table"); + QTest::addColumn<QString>("expected"); + + TablePtr table(new QtXmlToSphinx::Table); + TableRow row; + row << TableCell("item11") << TableCell("item12"); + table->appendRow(row); + row.clear(); + row << TableCell("") << TableCell("item22"); + table->appendRow(row); + row.clear(); + table->normalize(); + + const char *expected = R"(+------+------+ +|item11|item12| ++------+------+ +| |item22| ++------+------+ + +)"; + + QTest::newRow("normal") << table << QString::fromLatin1(expected); + + table.reset(new QtXmlToSphinx::Table); + row << TableCell("item11") << TableCell("item12\nline2"); + table->appendRow(row); + row.clear(); + row << TableCell("") << TableCell("item22\nline2\nline3"); + table->appendRow(row); + row.clear(); + table->normalize(); + + expected = R"(+------+------+ +|item11|item12| +| |line2 | ++------+------+ +| |item22| +| |line2 | +| |line3 | ++------+------+ + +)"; + + QTest::newRow("multi-line") << table << QString::fromLatin1(expected); +} + +void QtXmlToSphinxTest::testTableFormatting() +{ + QFETCH(TablePtr, table); + QFETCH(QString, expected); + + StringStream str; + table->format(str); + const QString actual = str.toString(); + + QCOMPARE(actual, expected); +} + QTEST_APPLESS_MAIN( QtXmlToSphinxTest) diff --git a/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h b/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h index 17afe162c..0459fdb6d 100644 --- a/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h +++ b/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h @@ -47,6 +47,8 @@ public: private slots: void testTable_data(); void testTable(); + void testTableFormatting_data(); + void testTableFormatting(); private: QString transformXml(const QString &xml) const; |