Add test case for get_local_windchill and improve function docs #39431
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: none
Purpose of change
To cover the behavior of
get_local_windchill
with tests, and improve the function itself by making its variable names more self-documenting.Describe the solution
Adds a test case covering both models of wind chill used; renames variables in the function itself and explicitly uses
std::ceil
for its return value instead of relying on the implicit type cast (which turns out to do the same thing asstd::ceil
for most of these test cases). Borrows several examples and explanatory text directly from the Wind chill Wikipedia article referenced in the function.Describe alternatives you've considered
This is not a very complicated function, and could have been tested with fewer lines of code by doing some kind of loop iteration, but I think unrolling the examples like this makes it easier for other developers/contributors to visualize the patterns (and easier to resolve if they fail).
Testing
Running
tests/cata_test [wind_chill]
as I went along.Additional context
Just one more piece in support of avatar health/bodytemp testing
Note, when I ran the new test case against the previous (unchanged) version of the
get_local_windchill
function; due to two of my changes (adjusting the cutoff for the North American model from 4F to 3F, per the Wikipedia article, and using an explicitstd::ceil
to convert the return value to an integer), a few of them are off from their previous value, but not by more than 1 degree.