From 8a6d4b06f2291c363f3dea17837ed20893852453 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Wed, 9 Sep 2015 19:00:56 +0200 Subject: Cleanup repo with some directories --- .../tests/auto/irctextformat/irctextformat.pro | 7 - .../tests/auto/irctextformat/tst_irctextformat.cpp | 192 --------------------- 2 files changed, 199 deletions(-) delete mode 100644 libcommuni/tests/auto/irctextformat/irctextformat.pro delete mode 100644 libcommuni/tests/auto/irctextformat/tst_irctextformat.cpp (limited to 'libcommuni/tests/auto/irctextformat') diff --git a/libcommuni/tests/auto/irctextformat/irctextformat.pro b/libcommuni/tests/auto/irctextformat/irctextformat.pro deleted file mode 100644 index 3b90b66..0000000 --- a/libcommuni/tests/auto/irctextformat/irctextformat.pro +++ /dev/null @@ -1,7 +0,0 @@ -###################################################################### -# Communi -###################################################################### - -SOURCES += tst_irctextformat.cpp - -include(../auto.pri) diff --git a/libcommuni/tests/auto/irctextformat/tst_irctextformat.cpp b/libcommuni/tests/auto/irctextformat/tst_irctextformat.cpp deleted file mode 100644 index 377a438..0000000 --- a/libcommuni/tests/auto/irctextformat/tst_irctextformat.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (C) 2008-2014 The Communi Project - * - * This test is free, and not covered by the BSD license. There is no - * restriction applied to their modification, redistribution, using and so on. - * You can study them, modify them, use them in your own program - either - * completely or partially. - */ - -#include "irc.h" -#include "irctextformat.h" -#include "ircpalette.h" -#include - -class tst_IrcTextFormat : public QObject -{ - Q_OBJECT - -private slots: - void testDefaults(); - void testPlainText_data(); - void testPlainText(); - void testHtml_data(); - void testHtml(); - void testUrls_data(); - void testUrls(); -}; - -void tst_IrcTextFormat::testDefaults() -{ - IrcTextFormat format; - QVERIFY(format.palette()); - QVERIFY(!format.urlPattern().isEmpty()); - QCOMPARE(format.spanFormat(), IrcTextFormat::SpanStyle); -} - -void tst_IrcTextFormat::testPlainText_data() -{ - QTest::addColumn("input"); - QTest::addColumn("output"); - - QTest::newRow("bold") << "\02bold\x0f" << "bold"; - QTest::newRow("line-through") << "\x13line-through\x0f" << "line-through"; - QTest::newRow("underline") << "\x15underline\x0f" << "underline"; - QTest::newRow("inverse") << "\x16inverse\x0f" << "inverse"; - QTest::newRow("italic") << "\x1ditalic\x0f" << "italic"; - QTest::newRow("underline") << "\x1funderline\x0f" << "underline"; - - IrcTextFormat format; - QVERIFY(format.palette()); - IrcPalette* palette = format.palette(); - for (int i = Irc::White; i <= Irc::LightGray; ++i) { - QString color = palette->colorName(i); - QTest::newRow(color.toUtf8()) << QString("\x03%1%2\x0f").arg(i).arg(color) << color; - } - - QTest::newRow("dummy \\x03") << "foo\x03 \02bold\x0f bar\x03" << "foo bold bar"; - QTest::newRow("extra \\x0f") << "foo\x0f \02bold\x0f bar\x0f" << "foo bold bar"; - QTest::newRow("background") << QString("foo \x03%1,%1red\x0f on \x03%1,%1red\x03 bar").arg(Irc::Red) << "foo red on red bar"; -} - -void tst_IrcTextFormat::testPlainText() -{ - QFETCH(QString, input); - QFETCH(QString, output); - - IrcTextFormat format; - QCOMPARE(format.toPlainText(input), output); - - format.parse(input); - QCOMPARE(format.plainText(), output); -} - -void tst_IrcTextFormat::testHtml_data() -{ - qRegisterMetaType(); - - QTest::addColumn("span"); - QTest::addColumn("input"); - QTest::addColumn("output"); - - QTest::newRow("style=bold") << IrcTextFormat::SpanStyle << "foo \02bold\x0f and \02bold\02 bar" << "foo bold and bold bar"; - QTest::newRow("class=bold") << IrcTextFormat::SpanClass << "foo \02bold\x0f and \02bold\02 bar" << "foo bold and bold bar"; - - QTest::newRow("style=line-through") << IrcTextFormat::SpanStyle << "foo \x13line\x0f and \x13through\x13 bar" << "foo line and through bar"; - QTest::newRow("class=line-through") << IrcTextFormat::SpanClass << "foo \x13line\x0f and \x13through\x13 bar" << "foo line and through bar"; - - QTest::newRow("style=underline1") << IrcTextFormat::SpanStyle << "foo \x15under\x0f and \x15line\x15 bar" << "foo under and line bar"; - - QTest::newRow("style=inverse") << IrcTextFormat::SpanStyle << "foo \x16inverse\x0f and \x16inverse\x16 bar" << "foo inverse and inverse bar"; - QTest::newRow("class=inverse") << IrcTextFormat::SpanClass << "foo \x16inverse\x0f and \x16inverse\x16 bar" << "foo inverse and inverse bar"; - - QTest::newRow("style=italic") << IrcTextFormat::SpanStyle << "foo \x1ditalic\x0f and \x1ditalic\x1d bar" << "foo italic and italic bar"; - QTest::newRow("class=italic") << IrcTextFormat::SpanClass << "foo \x1ditalic\x0f and \x1ditalic\x1d bar" << "foo italic and italic bar"; - - QTest::newRow("style=underline2") << IrcTextFormat::SpanStyle << "foo \x1funder\x0f and \x1fline\x1f bar" << "foo under and line bar"; - - IrcTextFormat format; - QVERIFY(format.palette()); - IrcPalette* palette = format.palette(); - for (int i = Irc::White; i <= Irc::LightGray; ++i) { - QString color = palette->colorName(i); - QTest::newRow(QString("style=%1").arg(color).toUtf8()) << IrcTextFormat::SpanStyle << QString("foo \x03%1%2\x0f and \x03%1%2\x03 bar").arg(i).arg(color) << QString("foo %1 and %1 bar").arg(color); - QTest::newRow(QString("class=%1").arg(color).toUtf8()) << IrcTextFormat::SpanClass << QString("foo \x03%1%2\x0f and \x03%1%2\x03 bar").arg(i).arg(color) << QString("foo %1 and %1 bar").arg(color); - } - - QTest::newRow("extra \\x0f") << IrcTextFormat::SpanStyle << "foo\x0f \02bold\x0f bar\x0f" << "foo bold bar"; - - QTest::newRow("style=background") << IrcTextFormat::SpanStyle << QString("foo \x03%1,%1red\x0f on \x03%1,%1red\x03 bar").arg(Irc::Red) << "foo red on red bar"; - QTest::newRow("class=background") << IrcTextFormat::SpanClass << QString("foo \x03%1,%1red\x0f on \x03%1,%1red\x03 bar").arg(Irc::Red) << "foo red on red bar"; -} - -void tst_IrcTextFormat::testHtml() -{ - QFETCH(IrcTextFormat::SpanFormat, span); - QFETCH(QString, input); - QFETCH(QString, output); - - IrcTextFormat format; - format.setSpanFormat(span); - QCOMPARE(format.toHtml(input), output); - - format.parse(input); - QCOMPARE(format.html(), output); -} - -Q_DECLARE_METATYPE(QList) -void tst_IrcTextFormat::testUrls_data() -{ - qRegisterMetaType >(); - - QTest::addColumn("pattern"); - QTest::addColumn("input"); - QTest::addColumn("output"); - QTest::addColumn >("urls"); - - QString defaultPattern = IrcTextFormat().urlPattern(); - - QTest::newRow("www.fi") << defaultPattern << "www.fi" << "www.fi" << (QList() << QUrl("http://www.fi")); - QTest::newRow("ftp.funet.fi") << defaultPattern << "ftp.funet.fi" << "ftp.funet.fi" << (QList() << QUrl("ftp://ftp.funet.fi")); - QTest::newRow("jpnurmi@gmail.com") << defaultPattern << "jpnurmi@gmail.com" << "jpnurmi@gmail.com" << (QList() << QUrl("mailto:jpnurmi@gmail.com")); - QTest::newRow("quote") << defaultPattern << "http://en.wikipedia.org/wiki/Shamir's_Secret_Sharing" << "http://en.wikipedia.org/wiki/Shamir's_Secret_Sharing" << (QList() << QUrl("http://en.wikipedia.org/wiki/Shamir's_Secret_Sharing")); - QTest::newRow("percent") << defaultPattern << "http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing" << "http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing" << (QList() << QUrl("http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing")); - QTest::newRow("parentheses") << defaultPattern << "http://en.wikipedia.org/wiki/Qt_(software)" << "http://en.wikipedia.org/wiki/Qt_(software)" << (QList() << QUrl("http://en.wikipedia.org/wiki/Qt_(software)")); - QTest::newRow("hash & comma") << defaultPattern << "https://codereview.qt-project.org/#change,1" << "https://codereview.qt-project.org/#change,1" << (QList() << QUrl("https://codereview.qt-project.org/#change,1")); - QTest::newRow("equal & question & ampersand") << defaultPattern << "https://www.google.no/imghp?hl=en&tab=wi" << "https://www.google.no/imghp?hl=en&tab=wi" << (QList() << QUrl("https://www.google.no/imghp?hl=en&tab=wi")); - QTest::newRow("github commits") << defaultPattern << "https://github.com/communi/libcommuni/compare/ebf3c8ea47dc...19d66ddcb122" << "https://github.com/communi/libcommuni/compare/ebf3c8ea47dc...19d66ddcb122" << (QList() << QUrl("https://github.com/communi/libcommuni/compare/ebf3c8ea47dc...19d66ddcb122")); - QTest::newRow("multiple") << defaultPattern << "www.fi ftp.funet.fi jpnurmi@gmail.com" << "www.fi ftp.funet.fi jpnurmi@gmail.com" << (QList() << QUrl("http://www.fi") << QUrl("ftp://ftp.funet.fi") << QUrl("mailto:jpnurmi@gmail.com")); - QTest::newRow("empty pattern") << QString() << "www.fi ftp.funet.fi jpnurmi@gmail.com" << "www.fi ftp.funet.fi jpnurmi@gmail.com" << QList(); - - QTest::newRow("info") << defaultPattern - << QString("[freenode-info] if you're at a conference and other people are having trouble connecting, please mention it to staff: http://freenode.net/faq.shtml#gettinghelp") - << QString("[freenode-info] if you're at a conference and other people are having trouble connecting, please mention it to staff: http://freenode.net/faq.shtml#gettinghelp") - << (QList() << QUrl("http://freenode.net/faq.shtml#gettinghelp")); - QTest::newRow("topic") << defaultPattern - << QString("Communi 1.2.2 - IRC framework || Home: http://communi.github.com || Docs: http://communi.github.com/doc || MeeGo: http://store.ovi.com/content/219150") - << QString("Communi 1.2.2 - IRC framework || Home: http://communi.github.com || Docs: http://communi.github.com/doc || MeeGo: http://store.ovi.com/content/219150") - << (QList() << QUrl("http://communi.github.com") << QUrl("http://communi.github.com/doc") << QUrl("http://store.ovi.com/content/219150")); - QTest::newRow("commit") << defaultPattern - << QString("[communi-desktop] jpnurmi pushed 2 new commits to master: https://github.com/communi/communi-desktop/compare/257ca915a490...8832bfe8d0b8") - << QString("[communi-desktop] jpnurmi pushed 2 new commits to master: https://github.com/communi/communi-desktop/compare/257ca915a490...8832bfe8d0b8") - << (QList() << QUrl("https://github.com/communi/communi-desktop/compare/257ca915a490...8832bfe8d0b8")); - QTest::newRow("with protocol") << defaultPattern - << QString("aa http://www.fi bb ftp://ftp.funet.fi cc") - << QString("aa http://www.fi bb ftp://ftp.funet.fi cc") - << (QList() << QUrl("http://www.fi") << QUrl("ftp://ftp.funet.fi")); - QTest::newRow("without protocol") << defaultPattern - << QString("aa www.fi bb ftp.funet.fi cc jpnurmi@gmail.com dd") - << QString("aa www.fi bb ftp.funet.fi cc jpnurmi@gmail.com dd") - << (QList() << QUrl("http://www.fi") << QUrl("ftp://ftp.funet.fi") << QUrl("mailto:jpnurmi@gmail.com")); -} - -void tst_IrcTextFormat::testUrls() -{ - QFETCH(QString, pattern); - QFETCH(QString, input); - QFETCH(QString, output); - QFETCH(QList, urls); - - IrcTextFormat format; - format.setUrlPattern(pattern); - QCOMPARE(format.urlPattern(), pattern); - QCOMPARE(format.toHtml(input), output); - - format.parse(input); - QCOMPARE(format.html(), output); - QCOMPARE(format.urls(), urls); -} - -QTEST_MAIN(tst_IrcTextFormat) - -#include "tst_irctextformat.moc" -- cgit v1.2.3-54-g00ecf