diff --git a/text/tests/wc/mod.rs b/text/tests/wc/mod.rs index 0b8a20e1..e29eceec 100644 --- a/text/tests/wc/mod.rs +++ b/text/tests/wc/mod.rs @@ -25,21 +25,21 @@ fn wc_test(args: &[&str], test_data: &str, expected_output: &str) { #[test] fn wc_empty() { - wc_test(&["-c"], "", "0\n"); - wc_test(&["-l"], "", "0\n"); - wc_test(&["-w"], "", "0\n"); + wc_test(&["-c"], "", "0 (stdin)\n"); + wc_test(&["-l"], "", "0 (stdin)\n"); + wc_test(&["-w"], "", "0 (stdin)\n"); } #[test] fn wc_one() { - wc_test(&["-c"], "x", "1\n"); - wc_test(&["-l"], "x", "0\n"); - wc_test(&["-w"], "x", "1\n"); + wc_test(&["-c"], "x", "1 (stdin)\n"); + wc_test(&["-l"], "x", "0 (stdin)\n"); + wc_test(&["-w"], "x", "1 (stdin)\n"); } #[test] fn wc_two() { - wc_test(&["-c"], "x y\n", "4\n"); - wc_test(&["-l"], "x y\n", "1\n"); - wc_test(&["-w"], "x y\n", "2\n"); + wc_test(&["-c"], "x y\n", "4 (stdin)\n"); + wc_test(&["-l"], "x y\n", "1 (stdin)\n"); + wc_test(&["-w"], "x y\n", "2 (stdin)\n"); } diff --git a/text/wc.rs b/text/wc.rs index 807b15fd..cd4e91fd 100644 --- a/text/wc.rs +++ b/text/wc.rs @@ -35,7 +35,7 @@ struct Args { #[arg(short = 'm', long)] chars: bool, - /// Count number of lines in each file + /// Count number of words in each file #[arg(short, long)] words: bool, @@ -106,15 +106,11 @@ fn build_display_str(args: &Args, count: &CountInfo, filename: &OsStr) -> String output.push_str(&numstr); } - let multi_file = args.files.len() > 1; - if multi_file { - output.push(' '); - - if filename.is_empty() { - output.push_str("(stdin)"); - } else { - output.push_str(filename.to_string_lossy().as_ref()); - } + output.push(' '); + if filename.is_empty() { + output.push_str("(stdin)"); + } else { + output.push_str(filename.to_string_lossy().as_ref()); } output