File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -457,6 +457,35 @@ mod tests {
457457 ) ;
458458 }
459459 #[ test]
460+ fn default_to_stdin ( ) {
461+ assert_eq ! (
462+ Ok ( Params {
463+ from: os( "foo" ) ,
464+ to: os( "/dev/stdin" ) ,
465+ ..Default :: default ( )
466+ } ) ,
467+ parse_params( [ os( "diff" ) , os( "foo" ) , os( "-" ) ] . iter( ) . cloned( ) )
468+ ) ;
469+ assert_eq ! (
470+ Ok ( Params {
471+ from: os( "/dev/stdin" ) ,
472+ to: os( "bar" ) ,
473+ ..Default :: default ( )
474+ } ) ,
475+ parse_params( [ os( "diff" ) , os( "-" ) , os( "bar" ) ] . iter( ) . cloned( ) )
476+ ) ;
477+ assert_eq ! (
478+ Ok ( Params {
479+ from: os( "/dev/stdin" ) ,
480+ to: os( "/dev/stdin" ) ,
481+ ..Default :: default ( )
482+ } ) ,
483+ parse_params( [ os( "diff" ) , os( "-" ) , os( "-" ) ] . iter( ) . cloned( ) )
484+ ) ;
485+ assert ! ( parse_params( [ os( "diff" ) , os( "foo" ) , os( "bar" ) , os( "-" ) ] . iter( ) . cloned( ) ) . is_err( ) ) ;
486+ assert ! ( parse_params( [ os( "diff" ) , os( "-" ) , os( "-" ) , os( "-" ) ] . iter( ) . cloned( ) ) . is_err( ) ) ;
487+ }
488+ #[ test]
460489 fn unknown_argument ( ) {
461490 assert ! (
462491 parse_params( [ os( "diff" ) , os( "-g" ) , os( "foo" ) , os( "bar" ) ] . iter( ) . cloned( ) ) . is_err( )
You can’t perform that action at this time.
0 commit comments