update test
This commit is contained in:
parent
6000dfdd02
commit
40d1768d49
|
@ -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>"
|
||||||
"<&>"
|
"<&><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"
|
||||||
"<&>"
|
"<&>\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);
|
||||||
|
|
Loading…
Reference in New Issue