From 0f132eb9b0964840f799d19f6ea5ee327d3cd6c9 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 27 Sep 2012 20:41:09 +0200 Subject: split QXmppUtils tests --- tests/all/tests.cpp | 96 ----------------------------------------------------- 1 file changed, 96 deletions(-) (limited to 'tests/all/tests.cpp') 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("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); -- cgit v1.2.3