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 sunrise, sunshine, sunset, and daylight tests #39951

Merged
merged 6 commits into from
Apr 29, 2020

Conversation

wapcaplet
Copy link
Contributor

@wapcaplet wapcaplet commented Apr 27, 2020

Summary

SUMMARY: Infrastructure "Add tests for sun-related functions"

Purpose of change

To test functions in calendar.cpp related to the sun, in preparation for refactoring several of them, as a roundabout way of homing in on functionality related to the light levels of cloudy moonlit skies.

Peripherally related to #38697

Describe the solution

Adds test cases to tests/sun_test.cpp and refactors some related functions in src/calendar.cpp.

  • New function added: is_day
  • Functions renamed: is_sunrise_now to is_dawn, is_sunset_now to is_dusk
  • Calendar functions tested: sunrise, sunset, is_night, is_dawn, is_dusk, is_day, sunlight, current_daylight_level, to_string, to_string_time_of_day

General sun-related behavior:

  • First day of spring and autum mark the equinoxes
  • First day of summer and winter mark the solstices
  • Dawn starts at sunrise and lasts 1 hour (twilight duration)
  • Dusk starts at sunset and lasts 1 hour
  • Sunlight
    • Increases at dawn
    • Maximum during the day
    • Decreases at dusk
    • Only moonlight at night
  • Sunrise and sunset
    • 7am - 5pm on winter solstice
    • 6am - 7pm on spring/autumn equinoxes
    • 5am - 9pm on summer solstice
  • Max sunlight is
    • 75% on winter solstice
    • 100% on spring/autumn equinoxes
    • 125% on summer solstice

Describe alternatives you've considered

Darkness

Testing

tests/cata_test [sun]

Additional context

Pretty happy with the current state of this one.

@wapcaplet wapcaplet changed the title [WIP] Add sun tests Add sunrise, sunshine, sunset, and daylight tests Apr 29, 2020
@ifreund ifreund added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Code: Tests Measurement, self-control, statistics, balancing. labels Apr 29, 2020
Copy link
Contributor

@ifreund ifreund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ifreund ifreund merged commit 12f3da5 into CleverRaven:master Apr 29, 2020
@wapcaplet wapcaplet deleted the cloudy-moon branch April 29, 2020 12:17
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: Infrastructure / Style / Static Analysis Code internal infrastructure and style Code: Tests Measurement, self-control, statistics, balancing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants