Skip to content

Commit ef13d7c

Browse files
committed
test to_calendar branches
1 parent 04d6906 commit ef13d7c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

components/calendar/src/date.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ impl<A> Copy for Date<A> where A: AsCalendar + Copy {}
616616
#[cfg(test)]
617617
mod tests {
618618
use super::*;
619-
use crate::types::Weekday;
619+
use crate::{Gregorian, cal::{Buddhist, Hebrew}, types::Weekday};
620620

621621
#[test]
622622
fn test_ord() {
@@ -665,4 +665,15 @@ mod tests {
665665
Weekday::Tuesday,
666666
);
667667
}
668+
669+
#[test]
670+
fn test_to_calendar() {
671+
let date = Date::try_new_gregorian(2025, 12, 9).unwrap();
672+
// These conversions uses the AbstractGregorian fast path
673+
let date2 = date.to_calendar(Buddhist).to_calendar(Gregorian);
674+
// These conversions go through RataDie
675+
let date3 = date.to_calendar(Hebrew).to_calendar(Gregorian);
676+
assert_eq!(date, date2);
677+
assert_eq!(date2, date3);
678+
}
668679
}

0 commit comments

Comments
 (0)