Skip to content

Commit

Permalink
Workaround for Cov CID1571023.
Browse files Browse the repository at this point in the history
Coverity thinks that there is a path which does not check that the
call to find() will not return end(). In fact, the previous ASSERT
should already have checked this, but however... This adds an
additional use of ASSERT_NE to guarantee the validity of the iterator
returned by find().
  • Loading branch information
paulhuggett committed Nov 18, 2023
1 parent b3ad08c commit 412d184
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion unittests/test_dom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ TEST_F (Dom, ArrayInsideObject) {
ASSERT_THAT (
obj, UnorderedElementsAre (Pair (u8"a"s, VariantWith<array> (_)),
Pair (u8"b"s, VariantWith<std::int64_t> (3))));
auto const &arr = *std::get<array> (obj.find (u8"a")->second);
auto const pos = obj.find (u8"a");
ASSERT_NE (pos, obj.end ());
auto const &arr = *std::get<array> (pos->second);
ASSERT_THAT (arr, ElementsAre (VariantWith<std::int64_t> (1),
VariantWith<std::int64_t> (2)));
}
Expand Down

0 comments on commit 412d184

Please sign in to comment.