@@ -9,6 +9,7 @@ use insta::assert_snapshot;
99use std:: fmt:: Write ;
1010
1111#[ test]
12+ #[ cfg( feature = "exhaustive" ) ]
1213fn test_date_add_across_calendars_and_durations ( ) {
1314 let calendars = vec ! [
1415 AnyCalendarKind :: Iso ,
@@ -339,34 +340,36 @@ fn test_date_add_across_calendars_and_durations() {
339340
340341 for duration in & durations {
341342 let mut date = start_date. clone ( ) ;
342- date. try_add_with_options ( * duration, opts)
343- . expect ( "Addition should succeed" ) ;
344343
345344 let duration_str = format ! (
346345 "{}{}{}{}" ,
347346 if duration. years != 0 {
348347 format!( "{}Y " , duration. years)
349348 } else {
350- "" . into ( )
349+ String :: new ( )
351350 } ,
352351 if duration. months != 0 {
353352 format!( "{}M " , duration. months)
354353 } else {
355- "" . into ( )
354+ String :: new ( )
356355 } ,
357356 if duration. weeks != 0 {
358357 format!( "{}W " , duration. weeks)
359358 } else {
360- "" . into ( )
359+ String :: new ( )
361360 } ,
362361 if duration. days != 0 {
363362 format!( "{}D" , duration. days)
364363 } else {
365- "" . into ( )
364+ String :: new ( )
366365 } ,
367366 ) ;
368367
369- writeln ! ( & mut calendar_output, " +{} → {:?}" , duration_str, date) . unwrap ( ) ;
368+ if date. try_add_with_options ( * duration, opts) . is_ok ( ) {
369+ writeln ! ( & mut calendar_output, " +{} → {:?}" , duration_str, date) . unwrap ( ) ;
370+ } else {
371+ writeln ! ( & mut calendar_output, " +{} → <invalid>" , duration_str) . unwrap ( ) ;
372+ }
370373 }
371374
372375 writeln ! ( & mut calendar_output) . unwrap ( ) ;
0 commit comments