diff --git a/cat/test.rs b/cat/test.rs index 1cfddfddf..3725f03f1 100644 --- a/cat/test.rs +++ b/cat/test.rs @@ -1,26 +1,19 @@ use std::{run, str}; -fn main() { - test_output_multi_files_print_all_chars(); - test_stdin_squeeze(); - test_stdin_number_non_blank(); - println("cat tests completed successfully!\n"); -} - +#[test] fn test_output_multi_files_print_all_chars() { let prog = run::process_output("build/cat", [~"cat/fixtures/alpha.txt", ~"cat/fixtures/256.txt", - ~"-A", ~"-n"]); - let out = str::from_utf8_owned(prog.unwrap().output); + ~"-A", ~"-n"]).unwrap(); + let out = str::from_utf8_owned(prog.output); assert_eq!(out, ~" 1\tabcde$\n 2\tfghij$\n 3\tklmno$\n 4\tpqrst$\n 5\tuvwxyz$\n 6\t^@^A^B^C^D^E^F^G^H^I$\n 7\t^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_ !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^ZM-^[M-^\\M-^]M-^^M-^_M- M-!M-\"M-#M-$M-%M-&M-\'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:M-;M-M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?"); } +#[test] fn test_stdin_squeeze() { - let program = run::Process::new("build/cat", [~"-A"], run::ProcessOptions::new()); - if program.is_none() { fail!("cat: error - process not started"); } + let mut prog = run::Process::new("build/cat", [~"-A"], run::ProcessOptions::new()).unwrap(); - let mut prog = program.unwrap(); prog.input().write(bytes!("\x00\x01\x02")); prog.close_input(); @@ -28,11 +21,10 @@ fn test_stdin_squeeze() { assert_eq!(out, ~"^@^A^B"); } +#[test] fn test_stdin_number_non_blank() { - let program = run::Process::new("build/cat", [~"-b", ~"-"], run::ProcessOptions::new()); - if program.is_none() { fail!("cat: error - process not started"); } + let mut prog = run::Process::new("build/cat", [~"-b", ~"-"], run::ProcessOptions::new()).unwrap(); - let mut prog = program.unwrap(); prog.input().write(bytes!("\na\nb\n\n\nc")); prog.close_input();