blob: add8f3c182bed4b1997c13b3e743c6173ec75d63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#include <QtTest/QtTest>
#include <TelepathyQt/Constants>
#include <TelepathyQt/Debug>
#include <TelepathyQt/Feature>
#include <TelepathyQt/Types>
using namespace Tp;
namespace {
QList<Feature> reverse(const QList<Feature> &list)
{
QList<Feature> ret(list);
for (int k = 0; k < (list.size() / 2); k++) {
#if QT_VERSION > QT_VERSION_CHECK(5, 13, 0)
ret.swapItemsAt(k, list.size() - (1 + k));
#else
ret.swap(k, list.size() - (1 + k));
#endif
}
return ret;
}
};
class TestFeatures : public QObject
{
Q_OBJECT
public:
TestFeatures(QObject *parent = 0);
private Q_SLOTS:
void testFeaturesHash();
};
TestFeatures::TestFeatures(QObject *parent)
: QObject(parent)
{
Tp::enableDebug(true);
Tp::enableWarnings(true);
}
void TestFeatures::testFeaturesHash()
{
QList<Feature> fs1;
QList<Feature> fs2;
for (int i = 0; i < 100; ++i) {
fs1 << Feature(QString::number(i), i);
fs2 << Feature(QString::number(i), i);
}
QCOMPARE(qHash(fs1.toSet()), qHash(fs2.toSet()));
fs2.clear();
for (int i = 0; i < 5; ++i) {
for (int j = 0; j < 100; ++j) {
fs2 << Feature(QString::number(j), j);
}
}
QCOMPARE(qHash(fs1.toSet()), qHash(fs2.toSet()));
fs1 = reverse(fs1);
QCOMPARE(qHash(fs1.toSet()), qHash(fs2.toSet()));
fs2 = reverse(fs2);
QCOMPARE(qHash(fs1.toSet()), qHash(fs2.toSet()));
fs2 << Feature(QLatin1String("100"), 100);
QVERIFY(qHash(fs1.toSet()) != qHash(fs2.toSet()));
}
QTEST_MAIN(TestFeatures)
#include "_gen/features.cpp.moc.hpp"
|