aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-02-08 13:18:52 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-02-09 16:37:35 +0100
commit720a4040bef4e614e4f03f4ae8b3c0f058d86be9 (patch)
tree45591a08cbb111d6bb48e6af42958dd2d80466ff
parentd95e30cae5f3c3d155b03d09a11f50d41a4b022e (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> (cherry picked from commit db824ef8c01b79a60c8029061eb5c86b51dd87fc) Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.cpp67
-rw-r--r--sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h2
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;