update test

This commit is contained in:
Patrick von Reth 2015-06-26 15:59:58 +02:00
parent 6000dfdd02
commit 40d1768d49
1 changed files with 9 additions and 18 deletions

View File

@ -25,41 +25,32 @@ public:
"<b>Bold</b><br>" "<b>Bold</b><br>"
"<u>Underline</u><br>" "<u>Underline</u><br>"
"<font color=\"blue\">Font</font><br>" "<font color=\"blue\">Font</font><br>"
"&lt;&amp;&gt;" "&lt;&amp;&gt;<br>"
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a><br>"); "<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a><br>");
private slots: private slots:
void benchmarkUtilsToHtml(); void benchmarkUtilsToHtml();
void benchmarkUtilsToHtmlAllMarkup(); void benchmarkUtilsToHtmlAllMarkup();
void benchmarkUtilsToPlain(); void benchmarkUtilsToPlain();
private:
/**
* old toPlaintext function from Utils.
* @param string A string to decode if needed.
* @return if the string was rhichtext or html encoded a decoded string, else the original string.
*/
static inline QString toPlainText(const QString &string)
{
if (Qt::mightBeRichText(string)) {
return QTextDocumentFragment::fromHtml(string).toPlainText();
} else {
return string;
}
}
}; };
void SnoreBenchmark::benchmarkUtilsToHtml(){ void SnoreBenchmark::benchmarkUtilsToHtml(){
QCOMPARE(Utils::normaliseMarkup(htmlTestString, Utils::NO_MARKUP), toPlainText(htmlTestString)); QCOMPARE(Utils::normaliseMarkup(htmlTestString, Utils::NO_MARKUP), QString("Italic A\n"
"Italic B\n"
"Bold\n"
"Underline\n"
"Font\n"
"<&>\n"
"Website\n"));
QCOMPARE(Utils::normaliseMarkup(htmlTestString, Utils::HREF), QString("Italic A\n" QCOMPARE(Utils::normaliseMarkup(htmlTestString, Utils::HREF), QString("Italic A\n"
"Italic B\n" "Italic B\n"
"Bold\n" "Bold\n"
"Underline\n" "Underline\n"
"Font\n" "Font\n"
"&lt;&amp;&gt;" "&lt;&amp;&gt;\n"
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a>\n")); "<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a>\n"));
QCOMPARE(Utils::normaliseMarkup(htmlTestString, Utils::HREF | Utils::BOLD | Utils::BREAK | QCOMPARE(Utils::normaliseMarkup(htmlTestString, Utils::HREF | Utils::BOLD | Utils::BREAK |
Utils::UNDERLINE | Utils::FONT | Utils::ITALIC), htmlTestString); Utils::UNDERLINE | Utils::FONT | Utils::ITALIC), htmlTestString);