1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

unexpand: allow multiple files & show error message if a directory is specified

* unexpand: should allow multiple files #5852 and unexpand: show error message if a directory is specified #5845

* test file added for #5845 #5852

* test case test_multiple_files improve

* cakebaker suggestion for a better code #5845 #5852

---------

Co-authored-by: biplab5464 <biplab5464@outlook.com>
This commit is contained in:
Biplab Mochan Gartia 2024-01-24 20:31:26 +05:30 committed by GitHub
parent f790349ffb
commit 150b287fe8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 5 deletions

View file

@ -2,6 +2,7 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore contenta
use crate::common::util::TestScenario;
#[test]
@ -235,3 +236,34 @@ fn test_tabs_shortcut_with_too_large_size() {
new_ucmd!().arg(arg).fails().stderr_contains(expected_error);
}
#[test]
fn test_is_directory() {
let (at, mut ucmd) = at_and_ucmd!();
let dir_name = "dir";
at.mkdir(dir_name);
ucmd.arg(dir_name)
.fails()
.stderr_contains(format!("unexpand: {}: Is a directory", dir_name));
}
#[test]
fn test_multiple_files() {
let (at, mut ucmd) = at_and_ucmd!();
at.write("file", "content");
at.write("file1", "a b");
ucmd.args(&["file", "file1"])
.succeeds()
.stdout_is("contenta b");
}
#[test]
fn test_one_nonexisting_file() {
new_ucmd!()
.arg("asdf.txt")
.fails()
.stderr_contains("asdf.txt: No such file or directory");
}