diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-27 19:37:27 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-28 09:24:50 (GMT) |
commit | 1f3218e086778a0e324542a00937cd44e8e10c79 (patch) | |
tree | d1d3813e330f8e0144ee003a7e6b68079ff6ea29 /tests/auto/qtextdocument/tst_qtextdocument.cpp | |
parent | de7de35082ec21d506a90e68cb30888540ec64cc (diff) | |
download | Qt-1f3218e086778a0e324542a00937cd44e8e10c79.zip Qt-1f3218e086778a0e324542a00937cd44e8e10c79.tar.gz Qt-1f3218e086778a0e324542a00937cd44e8e10c79.tar.bz2 |
Qt::escape(): also escape the quote (")
This amend previous commit by removing the duplicate function.
The quote need to be escaped in attributes.
Reviewed-by: Thomas Zander
Diffstat (limited to 'tests/auto/qtextdocument/tst_qtextdocument.cpp')
-rw-r--r-- | tests/auto/qtextdocument/tst_qtextdocument.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 452b683..5237438 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -176,6 +176,8 @@ private slots: void testUndoBlocks(); void receiveCursorPositionChangedAfterContentsChange(); + void escape_data(); + void escape(); private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); @@ -577,7 +579,7 @@ void tst_QTextDocument::task240325() } void tst_QTextDocument::stylesheetFont_data() -{ +{ QTest::addColumn<QString>("stylesheet"); QTest::addColumn<QFont>("font"); @@ -1566,7 +1568,7 @@ void tst_QTextDocument::toHtml() QString output = doc->toHtml(); QCOMPARE(output, expectedOutput); - + QDomDocument document; QVERIFY2(document.setContent(output), "Output was not valid XML"); } @@ -2680,5 +2682,25 @@ void tst_QTextDocument::receiveCursorPositionChangedAfterContentsChange() QCOMPARE(rec.first, QString("contentsChanged")); } +void tst_QTextDocument::escape_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_QTextDocument::escape() +{ + QFETCH(QString, original); + QFETCH(QString, expected); + + QCOMPARE(Qt::escape(original), expected); +} + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" |