diff options
author | Alexander Batischev <eual.jp@gmail.com> | 2020-09-04 19:49:19 +0300 |
---|---|---|
committer | Alexander Batischev <eual.jp@gmail.com> | 2020-09-04 20:15:18 +0300 |
commit | 07f1db05466f37c7c4258e668e0a6fa966e2ff0d (patch) | |
tree | a4771f6bfa5453d30d4e8c4397762e4a931c5659 /test/feedcontainer.cpp | |
parent | da5d3d352033e58a886c33ddf603bdb799e14254 (diff) |
FeedContainer::get_feed(): return nullptr on invalid index
Most callsites already check the return value for nullptr. I updated the
last one that didn't.
This is a stepping stone to avoiding a race condition in
Controller::mark_all_read() that @dennisschagt spotted:
https://github.com/newsboat/newsboat/pull/1166#discussion_r483483403
Diffstat (limited to 'test/feedcontainer.cpp')
-rw-r--r-- | test/feedcontainer.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/test/feedcontainer.cpp b/test/feedcontainer.cpp index e25279d4..2fc03b36 100644 --- a/test/feedcontainer.cpp +++ b/test/feedcontainer.cpp @@ -149,7 +149,8 @@ TEST_CASE( REQUIRE(feed == nullptr); } -TEST_CASE("Throws on get_feed() with pos out of range", "[FeedContainer]") +TEST_CASE("get_feed() returns nullptr if pos is out of range", + "[FeedContainer]") { FeedContainer feedcontainer; ConfigContainer cfg; @@ -157,8 +158,8 @@ TEST_CASE("Throws on get_feed() with pos out of range", "[FeedContainer]") feedcontainer.set_feeds(get_five_empty_feeds(&rsscache)); REQUIRE_NOTHROW(feedcontainer.get_feed(4)); - CHECK_THROWS_AS(feedcontainer.get_feed(5), std::out_of_range); - CHECK_THROWS_AS(feedcontainer.get_feed(-1), std::out_of_range); + REQUIRE(feedcontainer.get_feed(5) == nullptr); + REQUIRE(feedcontainer.get_feed(-1) == nullptr); } TEST_CASE("Returns correct number using get_feed_count_by_tag()", |