Remove or replace compare_err_stream_substring when an empty string is being compared#11648
Conversation
…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:
|
mitchute
left a comment
There was a problem hiding this comment.
Ready for review
| 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.
Requires the compare stream functions to need a non-empty string to compare against.
|
|
||
| ASSERT_TRUE(process_idf(idf_objects)); | ||
| compare_err_stream_substring("", true); // clear idf errors | ||
| compare_err_stream("", true); // clear idf errors |
There was a problem hiding this comment.
Converts to compare_err_stream so we don't accidentally mask actual errors.
| std::string const sizing_error_string = delimited_string({ | ||
| " ** Warning ** SizeDXCoil Coil:Cooling:DX:SingleSpeed ACDXCOIL 1", | ||
| " ** ~~~ ** ...Gross Rated Total Cooling Capacity [W] will be limited by the maximum rated volume flow per rated total capacity ratio.", | ||
| " ** ~~~ ** ...DX coil volume flow rate [m3/s] = 0.500000", | ||
| " ** ~~~ ** ...Requested capacity [W] = 75.000", | ||
| " ** ~~~ ** ...Requested flow/capacity ratio [m3/s/W] = 0.00666667", | ||
| " ** ~~~ ** ...Maximum flow/capacity ratio [m3/s/W] = 6.04100E-05", | ||
| " ** ~~~ ** ...Adjusted capacity [W] = 8276.775", | ||
| " ** Warning ** SizeHeatingCoil: : Potential issue with equipment sizing for Coil:Heating:Electric ZONE1OAUHEATINGCOIL", | ||
| " ** ~~~ ** ...Rated Total Heating Capacity = 0.00 [W]", | ||
| " ** ~~~ ** ...Capacity used to size child component set to 0 [W]", | ||
| }); | ||
| EXPECT_TRUE(compare_err_stream(sizing_error_string, true)); |
There was a problem hiding this comment.
This was being suppressed, so I'm adding the message here. If there's a separate issue with the model, that should probably be handled separately.
|
|
||
| ASSERT_TRUE(process_idf(idf_objects)); | ||
| compare_eio_stream_substring("", true); | ||
| compare_err_stream("", true); |
There was a problem hiding this comment.
I'm guessing the err stream was what was intended.
|
All good here. This one is next. |
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