@@ -22,25 +22,30 @@ fn unknown_param() -> Result<(), Box<dyn std::error::Error>> {
2222}
2323
2424#[ test]
25- fn cannot_read_from_file ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
25+ fn cannot_read_files ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
26+ let file = NamedTempFile :: new ( ) ?;
27+
2628 let mut cmd = Command :: cargo_bin ( "diffutils" ) ?;
27- cmd. arg ( "foo.txt" ) . arg ( "bar.txt" ) ;
29+ cmd. arg ( "foo.txt" ) . arg ( file . path ( ) ) ;
2830 cmd. assert ( )
2931 . code ( predicate:: eq ( 2 ) )
3032 . failure ( )
3133 . stderr ( predicate:: str:: starts_with ( "Failed to read from-file" ) ) ;
32- Ok ( ( ) )
33- }
3434
35- #[ test]
36- fn cannot_read_to_file ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
37- let file = NamedTempFile :: new ( ) ?;
3835 let mut cmd = Command :: cargo_bin ( "diffutils" ) ?;
39- cmd. arg ( file. path ( ) ) . arg ( "bar .txt" ) ;
36+ cmd. arg ( file. path ( ) ) . arg ( "foo .txt" ) ;
4037 cmd. assert ( )
4138 . code ( predicate:: eq ( 2 ) )
4239 . failure ( )
4340 . stderr ( predicate:: str:: starts_with ( "Failed to read to-file" ) ) ;
41+
42+ let mut cmd = Command :: cargo_bin ( "diffutils" ) ?;
43+ cmd. arg ( "foo.txt" ) . arg ( "foo.txt" ) ;
44+ cmd. assert ( )
45+ . code ( predicate:: eq ( 2 ) )
46+ . failure ( )
47+ . stderr ( predicate:: str:: starts_with ( "Failed to read from-file" ) ) ;
48+
4449 Ok ( ( ) )
4550}
4651
@@ -177,7 +182,7 @@ fn read_from_stdin() -> Result<(), Box<dyn std::error::Error>> {
177182 . code ( predicate:: eq ( 1 ) )
178183 . failure ( )
179184 . stdout ( predicate:: eq ( format ! (
180- "--- {}\t \n +++ /dev/stdin \t \n @@ -1 +1 @@\n -foo\n +bar\n " ,
185+ "--- {}\t \n +++ - \t \n @@ -1 +1 @@\n -foo\n +bar\n " ,
181186 file1. path( ) . to_string_lossy( )
182187 ) ) ) ;
183188
@@ -190,12 +195,12 @@ fn read_from_stdin() -> Result<(), Box<dyn std::error::Error>> {
190195 . code ( predicate:: eq ( 1 ) )
191196 . failure ( )
192197 . stdout ( predicate:: eq ( format ! (
193- "--- /dev/stdin \t \n +++ {}\t \n @@ -1 +1 @@\n -foo\n +bar\n " ,
198+ "--- - \t \n +++ {}\t \n @@ -1 +1 @@\n -foo\n +bar\n " ,
194199 file2. path( ) . to_string_lossy( )
195200 ) ) ) ;
196201
197202 let mut cmd = Command :: cargo_bin ( "diffutils" ) ?;
198- cmd. arg ( "-u" ) . arg ( "-" ) . arg ( "-" ) . write_stdin ( "foo \n " ) ;
203+ cmd. arg ( "-u" ) . arg ( "-" ) . arg ( "-" ) ;
199204 cmd. assert ( )
200205 . code ( predicate:: eq ( 0 ) )
201206 . success ( )
0 commit comments