#include #include #include #include #include using namespace Tp; namespace { QList reverse(const QList &list) { QList 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 = nullptr); private Q_SLOTS: void testFeaturesHash(); }; TestFeatures::TestFeatures(QObject *parent) : QObject(parent) { Tp::enableDebug(true); Tp::enableWarnings(true); } void TestFeatures::testFeaturesHash() { QList fs1; QList 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"