blob: c8c605d9e20b9434ab90bb124aac9bb11f428128 (
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
|
#include <QtTest/QtTest>
#include <TelepathyQt4/Constants>
#include <TelepathyQt4/Debug>
#include <TelepathyQt4/Feature>
#include <TelepathyQt4/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++) {
ret.swap(k, list.size() - (1 + k));
}
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"
|