File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,13 @@ fn replace_millisecond() -> Result<()> {
190190 Ok ( ( ) )
191191}
192192
193+ #[ test]
194+ fn replace_millisecond_regression ( ) {
195+ assert ! ( Time :: MIDNIGHT . replace_millisecond( 9999 ) . is_err( ) ) ;
196+ assert ! ( Time :: MIDNIGHT . replace_millisecond( 4294 ) . is_err( ) ) ;
197+ assert ! ( Time :: MIDNIGHT . replace_millisecond( 4295 ) . is_err( ) ) ;
198+ }
199+
193200#[ test]
194201fn replace_microsecond ( ) -> Result < ( ) > {
195202 assert_eq ! (
Original file line number Diff line number Diff line change @@ -284,8 +284,19 @@ macro_rules! ensure_ranged {
284284 } ;
285285
286286 ( $type: ident : $value: ident $( as $as_type: ident) ? * $factor: expr) => {
287- match $type:: new( $value $( as $as_type) ? * $factor) {
288- Some ( val) => val,
287+ match ( $value $( as $as_type) ?) . checked_mul( $factor) {
288+ Some ( val) => match $type:: new( val) {
289+ Some ( val) => val,
290+ None => {
291+ return Err ( crate :: error:: ComponentRange {
292+ name: stringify!( $value) ,
293+ minimum: $type:: MIN . get( ) as i64 / $factor as i64 ,
294+ maximum: $type:: MAX . get( ) as i64 / $factor as i64 ,
295+ value: $value as _,
296+ conditional_range: false ,
297+ } ) ;
298+ }
299+ } ,
289300 None => {
290301 return Err ( crate :: error:: ComponentRange {
291302 name: stringify!( $value) ,
You can’t perform that action at this time.
0 commit comments