| 4 | #include <meta/VersionList.h> |
| 5 | |
| 6 | class IndexTest : public QObject |
| 7 | { |
| 8 | Q_OBJECT |
| 9 | private |
| 10 | slots: |
| 11 | void test_hasUid_and_getList() |
| 12 | { |
| 13 | Meta::Index windex({std::make_shared<Meta::VersionList>("list1"), std::make_shared<Meta::VersionList>("list2"), std::make_shared<Meta::VersionList>("list3")}); |
| 14 | QVERIFY(windex.hasUid("list1")); |
| 15 | QVERIFY(!windex.hasUid("asdf")); |
| 16 | QVERIFY(windex.get("list2") != nullptr); |
| 17 | QCOMPARE(windex.get("list2")->uid(), QString("list2")); |
| 18 | QVERIFY(windex.get("adsf") != nullptr); |
| 19 | } |
| 20 | |
| 21 | void test_merge() |
| 22 | { |
| 23 | Meta::Index windex({std::make_shared<Meta::VersionList>("list1"), std::make_shared<Meta::VersionList>("list2"), std::make_shared<Meta::VersionList>("list3")}); |
| 24 | QCOMPARE(windex.lists().size(), 3); |
| 25 | 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")}))); |
| 26 | QCOMPARE(windex.lists().size(), 3); |
| 27 | 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")}))); |
| 28 | QCOMPARE(windex.lists().size(), 5); |
| 29 | windex.merge(std::shared_ptr<Meta::Index>(new Meta::Index({std::make_shared<Meta::VersionList>("list6")}))); |
| 30 | QCOMPARE(windex.lists().size(), 6); |
| 31 | } |
| 32 | }; |
| 33 | |
| 34 | QTEST_GUILESS_MAIN(IndexTest) |
| 35 | |