Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test case for get_local_windchill and improve function docs #39431

Merged
merged 6 commits into from
Apr 10, 2020

Conversation

wapcaplet
Copy link
Contributor

@wapcaplet wapcaplet commented Apr 10, 2020

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 as std::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 explicit std::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.

Based on the results of 33 test assertions, the implicit return cast to
int here is using `std::ceil` rather than `std::floor`.
According to Wikipedia, 3.0 is the cutoff for this model.
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Mechanics: Temperature Freezing, cooling, thawing, heating, etc. mechanics Mechanics: Weather Rain, snow, portal storms and non-temperature environment labels Apr 10, 2020
@ZhilkinSerg ZhilkinSerg merged commit 8be44fd into CleverRaven:master Apr 10, 2020
@wapcaplet wapcaplet deleted the wind-chill branch April 12, 2020 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Mechanics: Temperature Freezing, cooling, thawing, heating, etc. mechanics Mechanics: Weather Rain, snow, portal storms and non-temperature environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants