Dealing with branch coverage, I have seen many instances of code like this:
auto sharedPtr = weakPtr.lock();
if (sharedPtr != nullptr) {
...
}
In 99.9% of cases, sharedPtr != nullptr is always true, which means that our branch coverage can never be 100% and that is completely fine.
However, after a very quick look at the overall codebase, I could see that there are cases where we do NOT check for sharedPtr != nullptr and that is (very) bad practice. So, if anything, we really ought to ensure that our whole codebase always check for sharedPtr != nullptr.
Dealing with branch coverage, I have seen many instances of code like this:
In 99.9% of cases,
sharedPtr != nullptr
is alwaystrue
, which means that our branch coverage can never be 100% and that is completely fine.However, after a very quick look at the overall codebase, I could see that there are cases where we do NOT check for
sharedPtr != nullptr
and that is (very) bad practice. So, if anything, we really ought to ensure that our whole codebase always check forsharedPtr != nullptr
.