diff options
author | kmws <kamil.wsol@gmail.com> | 2018-06-14 23:01:57 +0200 |
---|---|---|
committer | kmws <kamil.wsol@gmail.com> | 2018-06-14 23:01:57 +0200 |
commit | 739e562aacfc7aa7146c22f4cfe64d682e4e336b (patch) | |
tree | 2681a95747c46dd4920ccb4569797cefdff9e877 /test/feedcontainer.cpp | |
parent | ce120331c420a64e5212f197ba87b44e1a70c221 (diff) |
Add test for sorting by articlecount
Diffstat (limited to 'test/feedcontainer.cpp')
-rw-r--r-- | test/feedcontainer.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/feedcontainer.cpp b/test/feedcontainer.cpp index 9520c89b..20bed4c3 100644 --- a/test/feedcontainer.cpp +++ b/test/feedcontainer.cpp @@ -287,12 +287,36 @@ TEST_CASE("Correctly sorts feeds", "[feedcontainer]") REQUIRE(sorted_feeds[4]->title() == "Zaza"); } + feeds[0]->add_item(std::make_shared<rss_item>(rsscache.get())); + feeds[0]->add_item(std::make_shared<rss_item>(rsscache.get())); + feeds[1]->add_item(std::make_shared<rss_item>(rsscache.get())); + feeds[1]->add_item(std::make_shared<rss_item>(rsscache.get())); + feeds[1]->add_item(std::make_shared<rss_item>(rsscache.get())); + feeds[2]->add_item(std::make_shared<rss_item>(rsscache.get())); + feeds[3]->add_item(std::make_shared<rss_item>(rsscache.get())); + SECTION("by articlecount asc") { + cfg->set_configvalue("feed-sort-order", "articlecount-asc"); + feedcontainer.sort_feeds(cfg.get()); + const auto sorted_feeds = feedcontainer.get_all_feeds(); + REQUIRE(sorted_feeds[0]->total_item_count() == 3); + REQUIRE(sorted_feeds[1]->total_item_count() == 2); + REQUIRE(sorted_feeds[2]->total_item_count() == 1); + REQUIRE(sorted_feeds[3]->total_item_count() == 1); + REQUIRE(sorted_feeds[4]->total_item_count() == 0); } SECTION("by articlecount desc") { + cfg->set_configvalue("feed-sort-order", "articlecount-desc"); + feedcontainer.sort_feeds(cfg.get()); + const auto sorted_feeds = feedcontainer.get_all_feeds(); + REQUIRE(sorted_feeds[0]->total_item_count() == 0); + REQUIRE(sorted_feeds[1]->total_item_count() == 1); + REQUIRE(sorted_feeds[2]->total_item_count() == 1); + REQUIRE(sorted_feeds[3]->total_item_count() == 2); + REQUIRE(sorted_feeds[4]->total_item_count() == 3); } SECTION("by unreadarticlecount asc") |