Index_test.cpp 1.5 KB

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