2017-03-11 00:39:45 +00:00
|
|
|
#include <QTest>
|
|
|
|
|
2022-09-11 21:25:18 +01:00
|
|
|
#include <meta/Index.h>
|
|
|
|
#include <meta/VersionList.h>
|
2017-03-11 00:39:45 +00:00
|
|
|
|
2023-08-02 17:35:35 +01:00
|
|
|
class IndexTest : public QObject {
|
2018-07-15 13:51:05 +01:00
|
|
|
Q_OBJECT
|
2023-08-02 17:35:35 +01:00
|
|
|
private slots:
|
2018-07-15 13:51:05 +01:00
|
|
|
void test_hasUid_and_getList()
|
|
|
|
{
|
2023-08-02 17:35:35 +01:00
|
|
|
Meta::Index windex({ std::make_shared<Meta::VersionList>("list1"), std::make_shared<Meta::VersionList>("list2"),
|
|
|
|
std::make_shared<Meta::VersionList>("list3") });
|
2018-07-15 13:51:05 +01:00
|
|
|
QVERIFY(windex.hasUid("list1"));
|
|
|
|
QVERIFY(!windex.hasUid("asdf"));
|
|
|
|
QVERIFY(windex.get("list2") != nullptr);
|
|
|
|
QCOMPARE(windex.get("list2")->uid(), QString("list2"));
|
|
|
|
QVERIFY(windex.get("adsf") != nullptr);
|
|
|
|
}
|
2017-03-11 00:39:45 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
void test_merge()
|
|
|
|
{
|
2023-08-02 17:35:35 +01:00
|
|
|
Meta::Index windex({ std::make_shared<Meta::VersionList>("list1"), std::make_shared<Meta::VersionList>("list2"),
|
|
|
|
std::make_shared<Meta::VersionList>("list3") });
|
2018-07-15 13:51:05 +01:00
|
|
|
QCOMPARE(windex.lists().size(), 3);
|
2023-08-02 17:35:35 +01:00
|
|
|
windex.merge(std::shared_ptr<Meta::Index>(
|
|
|
|
new Meta::Index({ std::make_shared<Meta::VersionList>("list1"), std::make_shared<Meta::VersionList>("list2"),
|
|
|
|
std::make_shared<Meta::VersionList>("list3") })));
|
2018-07-15 13:51:05 +01:00
|
|
|
QCOMPARE(windex.lists().size(), 3);
|
2023-08-02 17:35:35 +01:00
|
|
|
windex.merge(std::shared_ptr<Meta::Index>(
|
|
|
|
new Meta::Index({ std::make_shared<Meta::VersionList>("list4"), std::make_shared<Meta::VersionList>("list2"),
|
|
|
|
std::make_shared<Meta::VersionList>("list5") })));
|
2018-07-15 13:51:05 +01:00
|
|
|
QCOMPARE(windex.lists().size(), 5);
|
2023-08-02 17:35:35 +01:00
|
|
|
windex.merge(std::shared_ptr<Meta::Index>(new Meta::Index({ std::make_shared<Meta::VersionList>("list6") })));
|
2018-07-15 13:51:05 +01:00
|
|
|
QCOMPARE(windex.lists().size(), 6);
|
|
|
|
}
|
2017-03-11 00:39:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN(IndexTest)
|
|
|
|
|
|
|
|
#include "Index_test.moc"
|