Remove or replace compare_err_stream_substring when an empty string is being compared#11648
Remove or replace compare_err_stream_substring when an empty string is being compared#11648mitchute wants to merge 2 commits into
compare_err_stream_substring when an empty string is being compared#11648Conversation
…ssed when searching for substrings
|
Locally, I'm still seeing the following as a result of these changes: @rraustad do you have thoughts on this one? |
|
@mitchute changing from what you describe as a useless |
| if (search_string.empty()) { | ||
| ADD_FAILURE() << "compare_eio_stream_substring cannot search for an empty string; use compare_eso_stream or has_eso_output instead."; | ||
| return false; | ||
| } |
There was a problem hiding this comment.
I do like this though! Now we can't be lazy.
|
@rraustad the error I show above is a phantom error that was being thrown and hidden, but is now appearing. It's occurring due to this line being removed:
|
Pull request overview
The behavior of
compare_err_stream_substringappears to have been misunderstood, (propagated via copy/paste,) and possibly allowed errors to pass by uncaught. Forstd::string::find(""), C++ considers the empty string found at position 0 for any string, including another empty string. See the MWE, here.This makes usages like
compare_err_stream_substring("", true)ineffective at doing anything other than clearing the err stream. If the intent is really to expect an empty err stream, we should be usingcompare_err_streaminstead.This PR replaces those usages, and adds guards to protect against further misuse.
Description of the purpose of this PR
Pull Request Author
Reviewer