@@ -413,40 +413,34 @@ fn test_calendar_eras() {
413
413
) ;
414
414
}
415
415
416
- if era. start . is_some ( ) && calendar != "japanese" {
417
- assert_eq ! ( in_era. day_of_year( ) . 0 , 1 , "{calendar:?}" ) ;
418
- }
419
-
420
- match in_era. year ( ) {
421
- icu:: calendar:: types:: YearInfo :: Era ( era_year) => {
422
- // Unless this is the first era and it's not an inverse era, check that the
423
- // not_in_era date is in a different era
424
- if idx != 0 || era. end . is_some ( ) {
425
- assert_ne ! ( not_in_era. year( ) . era( ) . unwrap( ) . era, era_year. era) ;
426
- }
416
+ let icu:: calendar:: types:: YearInfo :: Era ( era_year) = in_era. year ( ) else {
417
+ continue ;
418
+ } ;
427
419
428
- // Check that the correct era code is returned
429
- if let Some ( code) = era. code . as_deref ( ) {
430
- assert_eq ! ( era_year. era, code) ;
431
- }
420
+ // Unless this is the first era and it's not an inverse era, check that the
421
+ // not_in_era date is in a different era
422
+ if idx != 0 || era. end . is_some ( ) {
423
+ assert_ne ! ( not_in_era. year( ) . era( ) . unwrap( ) . era, era_year. era) ;
424
+ }
432
425
433
- // Check that the start/end date uses year 1, and minimal/maximal month/day
434
- assert_eq ! ( era_year. year, 1 , "Didn't get correct year for {in_era:?}" ) ;
435
- }
436
- // Cyclic calendars use related_iso for their extended years, which won't
437
- // work with the CLDR "default" eras. Skip testing them.
438
- icu:: calendar:: types:: YearInfo :: Cyclic ( _) => ( ) ,
439
- _ => unreachable ! ( ) ,
426
+ // Check that the correct era code is returned
427
+ if let Some ( code) = era. code . as_deref ( ) {
428
+ assert_eq ! ( era_year. era, code) ;
440
429
}
441
430
431
+ // Check that the start/end date uses year 1, and minimal/maximal month/day
432
+ assert_eq ! ( era_year. year, 1 , "Didn't get correct year for {in_era:?}" ) ;
433
+
442
434
if calendar == "japanese" {
443
- // Japanese is the only calendar that doesn't have its own months
435
+ // Japanese is the only calendar that doesn't start eras on a new year
444
436
} else if era. start . is_some ( ) {
445
437
assert_eq ! ( in_era. month( ) . ordinal, 1 ) ;
446
438
assert_eq ! ( in_era. day_of_month( ) . 0 , 1 ) ;
439
+ assert_eq ! ( in_era. day_of_year( ) . 0 , 1 ) ;
447
440
} else {
448
441
assert_eq ! ( in_era. month( ) . ordinal, in_era. months_in_year( ) ) ;
449
442
assert_eq ! ( in_era. day_of_month( ) . 0 , in_era. days_in_month( ) ) ;
443
+ assert_eq ! ( in_era. day_of_year( ) . 0 , in_era. days_in_year( ) ) ;
450
444
}
451
445
}
452
446
}
0 commit comments