diff options
| author | Linus Jahn <lnj@kaidan.im> | 2020-02-10 22:16:12 +0100 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2020-02-11 16:19:40 +0100 |
| commit | f583f1a71459f413f9f869b8f1616722054dbea8 (patch) | |
| tree | b63ff44750dba3ffb92cf1b73c37ff44f0596eac /tests/qxmpputils/tst_qxmpputils.cpp | |
| parent | bfd26369d1ef032837fbd2b52ea0ed4cc04abe91 (diff) | |
| download | qxmpp-f583f1a71459f413f9f869b8f1616722054dbea8.tar.gz | |
utils: Generate UUIDs for stanza hashes by default
The QXmppUtils::generateStanzaHash() generates UUIDs by default now.
UUIDs are not generated, if the default parameter is changed to a
different value (!= 36). The behaviour is not changed for other values
than 36.
This way all users of QXmpp will automatically start to use UUIDs, if
they use the generateStanzaHash() method.
Diffstat (limited to 'tests/qxmpputils/tst_qxmpputils.cpp')
| -rw-r--r-- | tests/qxmpputils/tst_qxmpputils.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/qxmpputils/tst_qxmpputils.cpp b/tests/qxmpputils/tst_qxmpputils.cpp index 27424e1a..f879ba3a 100644 --- a/tests/qxmpputils/tst_qxmpputils.cpp +++ b/tests/qxmpputils/tst_qxmpputils.cpp @@ -37,6 +37,7 @@ private slots: void testJid(); void testMime(); void testTimezoneOffset(); + void testStanzaHash(); }; void tst_QXmppUtils::testCrc32() @@ -127,5 +128,21 @@ void tst_QXmppUtils::testTimezoneOffset() QCOMPARE(QXmppUtils::timezoneOffsetToString(-5400), QLatin1String("-01:30")); } +void tst_QXmppUtils::testStanzaHash() +{ + for (int i = 0; i < 100; i++) { + const QString hash = QXmppUtils::generateStanzaHash(i); + QCOMPARE(hash.size(), i); + + if (i == 36) { + QCOMPARE(hash.count('-'), 4); + } + } + + const QString hash = QXmppUtils::generateStanzaUuid(); + QCOMPARE(hash.size(), 36); + QCOMPARE(hash.count('-'), 4); +} + QTEST_MAIN(tst_QXmppUtils) #include "tst_qxmpputils.moc" |
