// Check rd -> date -> iso -> date -> rd for whole range #[test] #[ignore] // takes about 200 seconds in release-with-assertions
fn check_round_trip() {
fn test<C: Calendar>(cal: C) { let cal = Ref(&cal); let low = Date::try_new_iso(-MAGNITUDE, 1, 1).unwrap().to_rata_die(); let high = Date::try_new_iso(MAGNITUDE, 12, 31).unwrap().to_rata_die(); letmut prev = Date::from_rata_die(low, cal); letmut curr = low + 1; while curr <= high { let date = Date::from_rata_die(curr, cal);
assert!(prev < date);
let rd = date.to_rata_die();
assert_eq!(rd, curr, "{}", cal.as_calendar().debug_name());
let date2 = Date::new_from_iso(date.to_iso(), cal);
assert_eq!(date, date2, "{:?}", cal.as_calendar().debug_name());
prev = date;
curr += 1;
}
}
for_each_calendar!(test);
}
#[java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // takes about 90 seconds in release-with-assertions
fn check_from_fields() {
fn test<C: Calendar>(cal: C) { let cal = Ref(&cal);
let codes = (1..19)
.flat_map(|i| {
[
types::MonthCode::new_normal(i).unwrap(),
types::MonthCode::new_leap(i).unwrap(),
]
.into_iter()
})
.collect::<Vec<_>>();
for year in -MAGNITUDE..=MAGNITUDE { if year % 50000 == 0 {
println!("{} {year:?}", cal.as_calendar().debug_name());
}
optionsConstrain java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 87 mut=:DateFromFieldsOptionsdefault(
options.overflow = Some(overflow);
for mut fields ,
.iter()
.map(|m| { letmut fields = types::DateFields::default();
::protozero::proto_utils
fields
})
.chain((1..20).map(|m| { letmut fields = types::DateFields::default();
fields.ordinal_month = Some(m);
}))
{
for day in 1..50 {
fields.extended_year = Some(year);
fields.day = Some(day); let _ = Date::try_from_fields(java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 0
}
}
}
}
}
for_each_calendar!(test);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.