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 --- src/libcommuni/tests/benchmarks/benchmarks.pri | 9 ++++ src/libcommuni/tests/benchmarks/benchmarks.pro | 12 +++++ .../tests/benchmarks/ircmessage/ircmessage.pro | 7 +++ .../tests/benchmarks/ircmessage/tst_ircmessage.cpp | 61 +++++++++++++++++++++ .../ircmessagedecoder/ircmessagedecoder.pro | 7 +++ .../ircmessagedecoder/tst_ircmessagedecoder.cpp | 62 ++++++++++++++++++++++ .../benchmarks/irctextformat/irctextformat.pro | 7 +++ .../benchmarks/irctextformat/tst_irctextformat.cpp | 44 +++++++++++++++ 8 files changed, 209 insertions(+) create mode 100644 src/libcommuni/tests/benchmarks/benchmarks.pri create mode 100644 src/libcommuni/tests/benchmarks/benchmarks.pro create mode 100644 src/libcommuni/tests/benchmarks/ircmessage/ircmessage.pro create mode 100644 src/libcommuni/tests/benchmarks/ircmessage/tst_ircmessage.cpp create mode 100644 src/libcommuni/tests/benchmarks/ircmessagedecoder/ircmessagedecoder.pro create mode 100644 src/libcommuni/tests/benchmarks/ircmessagedecoder/tst_ircmessagedecoder.cpp create mode 100644 src/libcommuni/tests/benchmarks/irctextformat/irctextformat.pro create mode 100644 src/libcommuni/tests/benchmarks/irctextformat/tst_irctextformat.cpp (limited to 'src/libcommuni/tests/benchmarks') diff --git a/src/libcommuni/tests/benchmarks/benchmarks.pri b/src/libcommuni/tests/benchmarks/benchmarks.pri new file mode 100644 index 0000000..537efa0 --- /dev/null +++ b/src/libcommuni/tests/benchmarks/benchmarks.pri @@ -0,0 +1,9 @@ +###################################################################### +# Communi +###################################################################### + +QT = core network testlib +CONFIG += testcase +CONFIG -= app_bundle + +include(../tests.pri) diff --git a/src/libcommuni/tests/benchmarks/benchmarks.pro b/src/libcommuni/tests/benchmarks/benchmarks.pro new file mode 100644 index 0000000..ec48f5f --- /dev/null +++ b/src/libcommuni/tests/benchmarks/benchmarks.pro @@ -0,0 +1,12 @@ +###################################################################### +# Communi +###################################################################### + +TEMPLATE = subdirs + +SUBDIRS += ircmessage +SUBDIRS += irctextformat + +# - windows has problems with symbols +# - mac with private headers (frameworks) +!win32:!mac:SUBDIRS += ircmessagedecoder diff --git a/src/libcommuni/tests/benchmarks/ircmessage/ircmessage.pro b/src/libcommuni/tests/benchmarks/ircmessage/ircmessage.pro new file mode 100644 index 0000000..0a94dc8 --- /dev/null +++ b/src/libcommuni/tests/benchmarks/ircmessage/ircmessage.pro @@ -0,0 +1,7 @@ +###################################################################### +# Communi +###################################################################### + +SOURCES += tst_ircmessage.cpp + +include(../benchmarks.pri) diff --git a/src/libcommuni/tests/benchmarks/ircmessage/tst_ircmessage.cpp b/src/libcommuni/tests/benchmarks/ircmessage/tst_ircmessage.cpp new file mode 100644 index 0000000..47b1b5c --- /dev/null +++ b/src/libcommuni/tests/benchmarks/ircmessage/tst_ircmessage.cpp @@ -0,0 +1,61 @@ +/* + * 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 "ircmessage.h" +#include "ircconnection.h" +#include + +static const QByteArray MSG_32_5("Vestibulum eu libero eget metus."); +static const QByteArray MSG_64_9("Phasellus enim dui, sodales sed tincidunt quis, ultricies metus."); +static const QByteArray MSG_128_19("Ut porttitor volutpat tristique. Aenean semper ligula eget nulla condimentum tempor in quis felis. Sed sem diam, tincidunt amet."); +static const QByteArray MSG_256_37("Vestibulum quis lorem velit, a varius augue. Suspendisse risus augue, ultricies at convallis in, elementum in velit. Fusce fermentum congue augue sit amet dapibus. Fusce ultrices urna ut tortor laoreet a aliquet elit lobortis. Suspendisse volutpat posuere."); +static const QByteArray MSG_512_75("Nam leo risus, accumsan a sagittis eget, posuere eu velit. Morbi mattis auctor risus, vel consequat massa pulvinar nec. Proin aliquam convallis elit nec egestas. Pellentesque accumsan placerat augue, id volutpat nibh dictum vel. Aenean venenatis varius feugiat. Nullam molestie, ipsum id dignissim vulputate, eros urna vestibulum massa, in vehicula lacus nisi vitae risus. Ut nunc nunc, venenatis a mattis auctor, dictum et sem. Nulla posuere libero ut tortor elementum egestas. Aliquam egestas suscipit posuere."); + +class tst_IrcMessage : public QObject +{ + Q_OBJECT + +private slots: + void testFromData_data(); + void testFromData(); +}; + +void tst_IrcMessage::testFromData_data() +{ + QTest::addColumn("data"); + + QTest::newRow("null") << QByteArray(); + QTest::newRow("empty") << QByteArray(""); + + QTest::newRow("32 chars / 5 words") << MSG_32_5; + QTest::newRow("64 chars / 9 words") << MSG_64_9; + QTest::newRow("128 chars / 19 words") << MSG_128_19; + QTest::newRow("256 chars / 37 words") << MSG_256_37; + QTest::newRow("512 chars / 75 words") << MSG_512_75; + + QTest::newRow("32 chars / 5 words") << MSG_32_5; + QTest::newRow("64 chars / 9 words") << MSG_64_9; + QTest::newRow("128 chars / 19 words") << MSG_128_19; + QTest::newRow("256 chars / 37 words") << MSG_256_37; + QTest::newRow("512 chars / 75 words") << MSG_512_75; +} + +void tst_IrcMessage::testFromData() +{ + QFETCH(QByteArray, data); + + IrcConnection connection; + QBENCHMARK { + IrcMessage::fromData(data, &connection); + } +} + +QTEST_MAIN(tst_IrcMessage) + +#include "tst_ircmessage.moc" diff --git a/src/libcommuni/tests/benchmarks/ircmessagedecoder/ircmessagedecoder.pro b/src/libcommuni/tests/benchmarks/ircmessagedecoder/ircmessagedecoder.pro new file mode 100644 index 0000000..1ace28b --- /dev/null +++ b/src/libcommuni/tests/benchmarks/ircmessagedecoder/ircmessagedecoder.pro @@ -0,0 +1,7 @@ +###################################################################### +# Communi +###################################################################### + +SOURCES += tst_ircmessagedecoder.cpp + +include(../benchmarks.pri) diff --git a/src/libcommuni/tests/benchmarks/ircmessagedecoder/tst_ircmessagedecoder.cpp b/src/libcommuni/tests/benchmarks/ircmessagedecoder/tst_ircmessagedecoder.cpp new file mode 100644 index 0000000..f26e1f8 --- /dev/null +++ b/src/libcommuni/tests/benchmarks/ircmessagedecoder/tst_ircmessagedecoder.cpp @@ -0,0 +1,62 @@ +/* + * 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 "ircmessagedecoder_p.h" +#include +#include +#include + +static const QByteArray MSG_32_5("Vestibulum eu libero eget metus."); +static const QByteArray MSG_64_9("Phasellus enim dui, sodales sed tincidunt quis, ultricies metus."); +static const QByteArray MSG_128_19("Ut porttitor volutpat tristique. Aenean semper ligula eget nulla condimentum tempor in quis felis. Sed sem diam, tincidunt amet."); +static const QByteArray MSG_256_37("Vestibulum quis lorem velit, a varius augue. Suspendisse risus augue, ultricies at convallis in, elementum in velit. Fusce fermentum congue augue sit amet dapibus. Fusce ultrices urna ut tortor laoreet a aliquet elit lobortis. Suspendisse volutpat posuere."); +static const QByteArray MSG_512_75("Nam leo risus, accumsan a sagittis eget, posuere eu velit. Morbi mattis auctor risus, vel consequat massa pulvinar nec. Proin aliquam convallis elit nec egestas. Pellentesque accumsan placerat augue, id volutpat nibh dictum vel. Aenean venenatis varius feugiat. Nullam molestie, ipsum id dignissim vulputate, eros urna vestibulum massa, in vehicula lacus nisi vitae risus. Ut nunc nunc, venenatis a mattis auctor, dictum et sem. Nulla posuere libero ut tortor elementum egestas. Aliquam egestas suscipit posuere."); + +class tst_IrcMessageDecoder : public QObject +{ + Q_OBJECT + +private slots: + void testDecode_data(); + void testDecode(); +}; + +void tst_IrcMessageDecoder::testDecode_data() +{ + QTest::addColumn("data"); + + QTest::newRow("null") << QByteArray(); + QTest::newRow("empty") << QByteArray(""); + + QTest::newRow("32 chars / 5 words") << MSG_32_5; + QTest::newRow("64 chars / 9 words") << MSG_64_9; + QTest::newRow("128 chars / 19 words") << MSG_128_19; + QTest::newRow("256 chars / 37 words") << MSG_256_37; + QTest::newRow("512 chars / 75 words") << MSG_512_75; + + QTest::newRow("32 chars / 5 words") << MSG_32_5; + QTest::newRow("64 chars / 9 words") << MSG_64_9; + QTest::newRow("128 chars / 19 words") << MSG_128_19; + QTest::newRow("256 chars / 37 words") << MSG_256_37; + QTest::newRow("512 chars / 75 words") << MSG_512_75; +} + +void tst_IrcMessageDecoder::testDecode() +{ + QFETCH(QByteArray, data); + + IrcMessageDecoder decoder; + QBENCHMARK { + decoder.decode(data, "ISO-8859-15"); + } +} + +QTEST_MAIN(tst_IrcMessageDecoder) + +#include "tst_ircmessagedecoder.moc" diff --git a/src/libcommuni/tests/benchmarks/irctextformat/irctextformat.pro b/src/libcommuni/tests/benchmarks/irctextformat/irctextformat.pro new file mode 100644 index 0000000..61091aa --- /dev/null +++ b/src/libcommuni/tests/benchmarks/irctextformat/irctextformat.pro @@ -0,0 +1,7 @@ +###################################################################### +# Communi +###################################################################### + +SOURCES += tst_irctextformat.cpp + +include(../benchmarks.pri) diff --git a/src/libcommuni/tests/benchmarks/irctextformat/tst_irctextformat.cpp b/src/libcommuni/tests/benchmarks/irctextformat/tst_irctextformat.cpp new file mode 100644 index 0000000..1da9483 --- /dev/null +++ b/src/libcommuni/tests/benchmarks/irctextformat/tst_irctextformat.cpp @@ -0,0 +1,44 @@ +/* + * 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 "irctextformat.h" +#include + +class tst_IrcTextFormat : public QObject +{ + Q_OBJECT + +private slots: + void testToHtml_data(); + void testToHtml(); +}; + +void tst_IrcTextFormat::testToHtml_data() +{ + QTest::addColumn("text"); + + QTest::newRow("info") << 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"); + QTest::newRow("topic") << 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"); + QTest::newRow("commit") << QString("[communi-desktop] jpnurmi pushed 2 new commits to master: https://github.com/communi/communi-desktop/compare/257ca915a490...8832bfe8d0b8"); + QTest::newRow("welcome") << QString("Welcome to the Communi development lounge. Communi for MeeGo/Symbian users are kindly asked to submit a review in Nokia Store."); +} + +void tst_IrcTextFormat::testToHtml() +{ + QFETCH(QString, text); + + IrcTextFormat format; + QBENCHMARK { + format.toHtml(text); + } +} + +QTEST_MAIN(tst_IrcTextFormat) + +#include "tst_irctextformat.moc" -- cgit v1.2.3-54-g00ecf