@@ -24,22 +24,28 @@ Here's a trivial example:
2424
2525``` rust
2626extern crate assert_cli;
27- assert_cli :: assert_cli_output (" echo" , & [" 42" ], " 42" ). unwrap ();
27+ fn main () {
28+ assert_cli :: assert_cli_output (" echo" , & [" 42" ], " 42" ). unwrap ();
29+ }
2830```
2931
3032Or if you'd rather use the macro:
3133
3234``` rust,ignore
3335#[macro_use] extern crate assert_cli;
34- assert_cli!("echo", &["42"] => Success, "42").unwrap();
35- assert_cli!("black-box", &["--special"] => Error 42, "error no 42\n").unwrap()
36+ fn main() {
37+ assert_cli!("echo", &["42"] => Success, "42").unwrap();
38+ assert_cli!("black-box", &["--special"] => Error 42, "error no 42\n").unwrap()
39+ }
3640```
3741
3842And here is one that will fail:
3943
4044``` rust,should_panic
4145extern crate assert_cli;
42- assert_cli::assert_cli_output("echo", &["42"], "1337").unwrap();
46+ fn main() {
47+ assert_cli::assert_cli_output("echo", &["42"], "1337").unwrap();
48+ }
4349```
4450
4551this will show a nice, colorful diff in your terminal, like this:
@@ -53,18 +59,22 @@ If you'd prefer to not check the output:
5359
5460``` rust
5561#[macro_use] extern crate assert_cli;
56- assert_cli :: assert_cli (" echo" , & [" 42" ]). unwrap ();
57- assert_cli! (" echo" , & [" 42" ] => Success ). unwrap ();
62+ fn main () {
63+ assert_cli :: assert_cli (" echo" , & [" 42" ]). unwrap ();
64+ assert_cli! (" echo" , & [" 42" ] => Success ). unwrap ();
65+ }
5866```
5967
6068All exported functions and the macro return a ` Result ` containing the
6169` Output ` of the process, allowing you to do further custom assertions:
6270
6371``` rust
6472#[macro_use] extern crate assert_cli;
65- let output = assert_cli! (" echo" , & [" Number 42" ] => Success ). unwrap ();
66- let stdout = std :: str :: from_utf8 (& output . stdout). unwrap ();
67- assert! (stdout . contains (" 42" ));
73+ fn main () {
74+ let output = assert_cli! (" echo" , & [" Number 42" ] => Success ). unwrap ();
75+ let stdout = std :: str :: from_utf8 (& output . stdout). unwrap ();
76+ assert! (stdout . contains (" 42" ));
77+ }
6878```
6979
7080## License
0 commit comments