aboutsummaryrefslogtreecommitdiff
path: root/tests/all/tests.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-09-27 20:41:09 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-09-27 20:41:09 +0200
commit0f132eb9b0964840f799d19f6ea5ee327d3cd6c9 (patch)
tree83dd478f4b970a4f6e9e21cf183abab687c97745 /tests/all/tests.cpp
parent6c944f97b202bc8d1c3ee25259455170ea82a80d (diff)
downloadqxmpp-0f132eb9b0964840f799d19f6ea5ee327d3cd6c9.tar.gz
split QXmppUtils tests
Diffstat (limited to 'tests/all/tests.cpp')
-rw-r--r--tests/all/tests.cpp96
1 files changed, 0 insertions, 96 deletions
diff --git a/tests/all/tests.cpp b/tests/all/tests.cpp
index a7095408..640c26e4 100644
--- a/tests/all/tests.cpp
+++ b/tests/all/tests.cpp
@@ -48,99 +48,6 @@
#include "tests.h"
#include "util.h"
-void TestUtils::testCrc32()
-{
- quint32 crc = QXmppUtils::generateCrc32(QByteArray());
- QCOMPARE(crc, 0u);
-
- crc = QXmppUtils::generateCrc32(QByteArray("Hi There"));
- QCOMPARE(crc, 0xDB143BBEu);
-}
-
-void TestUtils::testHmac()
-{
- QByteArray hmac = QXmppUtils::generateHmacMd5(QByteArray(16, 0x0b), QByteArray("Hi There"));
- QCOMPARE(hmac, QByteArray::fromHex("9294727a3638bb1c13f48ef8158bfc9d"));
-
- hmac = QXmppUtils::generateHmacMd5(QByteArray("Jefe"), QByteArray("what do ya want for nothing?"));
- QCOMPARE(hmac, QByteArray::fromHex("750c783e6ab0b503eaa86e310a5db738"));
-
- hmac = QXmppUtils::generateHmacMd5(QByteArray(16, 0xaa), QByteArray(50, 0xdd));
- QCOMPARE(hmac, QByteArray::fromHex("56be34521d144c88dbb8c733f0e8b3f6"));
-}
-
-void TestUtils::testJid()
-{
- QCOMPARE(QXmppUtils::jidToBareJid("foo@example.com/resource"), QLatin1String("foo@example.com"));
- QCOMPARE(QXmppUtils::jidToBareJid("foo@example.com"), QLatin1String("foo@example.com"));
- QCOMPARE(QXmppUtils::jidToBareJid("example.com"), QLatin1String("example.com"));
- QCOMPARE(QXmppUtils::jidToBareJid(QString()), QString());
-
- QCOMPARE(QXmppUtils::jidToDomain("foo@example.com/resource"), QLatin1String("example.com"));
- QCOMPARE(QXmppUtils::jidToDomain("foo@example.com"), QLatin1String("example.com"));
- QCOMPARE(QXmppUtils::jidToDomain("example.com"), QLatin1String("example.com"));
- QCOMPARE(QXmppUtils::jidToDomain(QString()), QString());
-
- QCOMPARE(QXmppUtils::jidToResource("foo@example.com/resource"), QLatin1String("resource"));
- QCOMPARE(QXmppUtils::jidToResource("foo@example.com"), QString());
- QCOMPARE(QXmppUtils::jidToResource("example.com"), QString());
- QCOMPARE(QXmppUtils::jidToResource(QString()), QString());
-
- QCOMPARE(QXmppUtils::jidToUser("foo@example.com/resource"), QLatin1String("foo"));
- QCOMPARE(QXmppUtils::jidToUser("foo@example.com"), QLatin1String("foo"));
- QCOMPARE(QXmppUtils::jidToUser("example.com"), QString());
- QCOMPARE(QXmppUtils::jidToUser(QString()), QString());
-}
-
-// FIXME: how should we test MIME detection without expose getImageType?
-#if 0
-QString getImageType(const QByteArray &contents);
-
-static void testMimeType(const QString &fileName, const QString fileType)
-{
- // load file from resources
- QFile file(":/" + fileName);
- QCOMPARE(file.open(QIODevice::ReadOnly), true);
- QCOMPARE(getImageType(file.readAll()), fileType);
- file.close();
-}
-
-void TestUtils::testMime()
-{
- testMimeType("test.bmp", "image/bmp");
- testMimeType("test.gif", "image/gif");
- testMimeType("test.jpg", "image/jpeg");
- testMimeType("test.mng", "video/x-mng");
- testMimeType("test.png", "image/png");
- testMimeType("test.svg", "image/svg+xml");
- testMimeType("test.xpm", "image/x-xpm");
-}
-#else
-void TestUtils::testMime()
-{
-}
-#endif
-
-void TestUtils::testLibVersion()
-{
- QCOMPARE(QXmppVersion(), QString("0.7.3"));
-}
-
-void TestUtils::testTimezoneOffset()
-{
- // parsing
- QCOMPARE(QXmppUtils::timezoneOffsetFromString("Z"), 0);
- QCOMPARE(QXmppUtils::timezoneOffsetFromString("+00:00"), 0);
- QCOMPARE(QXmppUtils::timezoneOffsetFromString("-00:00"), 0);
- QCOMPARE(QXmppUtils::timezoneOffsetFromString("+01:30"), 5400);
- QCOMPARE(QXmppUtils::timezoneOffsetFromString("-01:30"), -5400);
-
- // serialization
- QCOMPARE(QXmppUtils::timezoneOffsetToString(0), QLatin1String("Z"));
- QCOMPARE(QXmppUtils::timezoneOffsetToString(5400), QLatin1String("+01:30"));
- QCOMPARE(QXmppUtils::timezoneOffsetToString(-5400), QLatin1String("-01:30"));
-}
-
void TestPackets::testArchiveList_data()
{
QTest::addColumn<QByteArray>("xml");
@@ -870,9 +777,6 @@ int main(int argc, char *argv[])
// run tests
int errors = 0;
- TestUtils testUtils;
- errors += QTest::qExec(&testUtils);
-
TestPackets testPackets;
errors += QTest::qExec(&testPackets);