File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -349,4 +349,28 @@ mod tests {
349349 let sum: NumOpResult < SignedAmount > = amounts. into_iter ( ) . sum ( ) ;
350350 assert_eq ! ( sum, NumOpResult :: Valid ( SignedAmount :: from_sat_i32( 250 ) ) ) ;
351351 }
352+
353+ #[ test]
354+ fn test_sum_signed_amount_results_with_references ( ) {
355+ let amounts = [
356+ NumOpResult :: Valid ( SignedAmount :: from_sat_i32 ( 100 ) ) ,
357+ NumOpResult :: Valid ( SignedAmount :: from_sat_i32 ( -50 ) ) ,
358+ NumOpResult :: Valid ( SignedAmount :: from_sat_i32 ( 200 ) ) ,
359+ ] ;
360+
361+ let sum: NumOpResult < SignedAmount > = amounts. iter ( ) . sum ( ) ;
362+ assert_eq ! ( sum, NumOpResult :: Valid ( SignedAmount :: from_sat_i32( 250 ) ) ) ;
363+ }
364+
365+ #[ test]
366+ fn test_sum_signed_amount_with_error_propagation ( ) {
367+ let amounts = [
368+ NumOpResult :: Valid ( SignedAmount :: from_sat_i32 ( 100 ) ) ,
369+ NumOpResult :: Error ( NumOpError :: while_doing ( MathOp :: Add ) ) ,
370+ NumOpResult :: Valid ( SignedAmount :: from_sat_i32 ( 200 ) ) ,
371+ ] ;
372+
373+ let sum: NumOpResult < SignedAmount > = amounts. into_iter ( ) . sum ( ) ;
374+ assert ! ( matches!( sum, NumOpResult :: Error ( _) ) ) ;
375+ }
352376}
You can’t perform that action at this time.
0 commit comments