diff options
Diffstat (limited to 'tests/auto/corelib/tools/qstring')
-rw-r--r-- | tests/auto/corelib/tools/qstring/tst_qstring.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 176becb06c..1721f80a8f 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -226,6 +226,8 @@ private slots: void literals(); void reserve(); + void toHtmlEscaped_data(); + void toHtmlEscaped(); }; typedef QList<int> IntList; @@ -5144,6 +5146,26 @@ void tst_QString::reserve() nil2.reserve(0); } +void tst_QString::toHtmlEscaped_data() +{ + QTest::addColumn<QString>("original"); + QTest::addColumn<QString>("expected"); + + QTest::newRow("1") << "Hello World\n" << "Hello World\n"; + QTest::newRow("2") << "#include <QtCore>" << "#include <QtCore>"; + QTest::newRow("3") << "<p class=\"cool\"><a href=\"http://example.com/?foo=bar&bar=foo\">plop --> </a></p>" + << "<p class="cool"><a href="http://example.com/?foo=bar&amp;bar=foo">plop --&gt; </a></p>"; + QTest::newRow("4") << QString::fromUtf8("<\320\222\321\201>") << QString::fromUtf8("<\320\222\321\201>"); +} + +void tst_QString::toHtmlEscaped() +{ + QFETCH(QString, original); + QFETCH(QString, expected); + + QCOMPARE(original.toHtmlEscaped(), expected); +} + QTEST_APPLESS_MAIN(tst_QString) #include "tst_qstring.moc" |