-
Notifications
You must be signed in to change notification settings - Fork 226
Add tests for NotEnoughFieldsError priority in Date::from_fields #7098
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
Conversation
components/calendar/src/date.rs
Outdated
let reject = DateFromFieldsOptions { | ||
overflow: Some(Overflow::Reject), | ||
..Default::default() | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It would be best to check this with all the modes:
- Overflow Reject, Missing Fields Reject
- Overflow Reject, Missing Fields Ecma
- Overflow Constrain, Missing Fields Reject
- Overflow Constrain, Missing Fields Ecma
It's a uniquely complex function with a lot of code paths and I want them to all be covered.
components/calendar/src/date.rs
Outdated
extended_year: Some(i32::MAX), | ||
ordinal_month: Some(100), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, here and elsewhere: set only one of the fields to be out of bounds at a time, again to make sure we are covering all of the cases
I moved it to a separate file (because it's getting big), and I think I tested most cases. |
a8c172a
to
0aa72ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better, thanks. Two more suggestions
|
||
mod continuity_test; | ||
mod extrema; | ||
mod not_enough_fields; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: crate/src/tests
is a weird thing specifically in icu_calendar
for tests that need to access pub(crate)
items. Most tests should go into crate/tests
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I made this choice because the test gets much more ugly because of non_exhaustive.
Fixes #7083