-
Notifications
You must be signed in to change notification settings - Fork 546
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
Merge 0.4.x #1401
Merged
Merged
Merge 0.4.x #1401
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added tests for creating the maximum and minimum allowable values of Durations having a magnitude of seconds, testing the limits plus one value beyond the limits in both directions. These tests all pass. - Expanded the tests for creating the maximum and minimum allowable values of Durations having a magnitude of milliseconds. These tests examine the results in more detail, document what is being tested, and also test one value beyond the limits in both directions. Notably, the test for Duration::milliseconds() construction for i64::MIN currently fails, as it is erroneously allowed. This test is ignored for now, until the fix is applied. - Expanded the tests for creating the maximum and minimum allowable values of Durations having a magnitude of microseconds and nanoseconds. These tests examine the results in more detail, document what is being tested, and also test one value beyond the limits in both directions. They also test the maximum reportable value from .num_*() and the maximum storable value of the Duration separately. - Separated out the tests for MAX and MIN, for clarity. - Added additional tests for addition and subtraction operations on Durations, ensuring that equivalent tests are performed against both operations, such as adding and subtracting zero, adding and subtracting one nanosecond, and others. - Added tests for greater-than and less-than comparison of two Durations, to ensure that internal representation of partial seconds is correctly ordered.
- Added Panics and Errors sections where appropriate, as these are generally-expected and help draw attention to the fact that the standard (i.e. non-try) constructors can panic. The Errors section for the try constructors is common practice when returning None for overflow situations as well as for functions actually returning a Result. - Added an further explanation of the behaviour of the seconds() constructor. - Minor additional readability edits.
- Added a new Duration::try_milliseconds() function, to attempt to create a new milliseconds-based Duration, and return None if it fails, based on checking against MAX and MIN. Currently, failure can only happen for exactly one value, which is i64::MIN. - Updated Duration::milliseconds() to call try_milliseconds() and panic if None is returned. Although panicking in production code and especially library code is bad, this is in keeping with current Chrono behaviour. Note that this function is now no longer const. - Updated the Duration::milliseconds() documentation to make it clear that it now panics. - Added documentation to Duration::microseconds() and nanoseconds() to make it clear that they are infallible. - All tests now pass, including the one previously ignored.
- Added a description of internal storage and permissable range to the Duration type. - Adjusted formatting of `Duration` in a number of related function Rustdoc blocks, to aid readability. - Clarified comments for Duration::num_milliseconds().
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## 0.5.x #1401 +/- ##
==========================================
+ Coverage 93.41% 93.51% +0.09%
==========================================
Files 34 34
Lines 16754 17018 +264
==========================================
+ Hits 15651 15914 +263
- Misses 1103 1104 +1 ☔ View full report in Codecov by Sentry. |
djc
approved these changes
Feb 2, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This will bring the first two commits of #1394 (merged in #1395) to the 0.5.x branch.