mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-15 03:26:18 +00:00
Merge pull request #5966 from Ideflop/more-implement-argument-pattern
More implement argument pattern
This commit is contained in:
commit
77a67559eb
2 changed files with 138 additions and 9 deletions
|
@ -34,6 +34,9 @@ fn test_valid_arg() {
|
|||
|
||||
new_ucmd!().arg("-F").arg("10").succeeds();
|
||||
new_ucmd!().arg("--from-line").arg("0").succeeds();
|
||||
|
||||
new_ucmd!().arg("-P").arg("something").succeeds();
|
||||
new_ucmd!().arg("--pattern").arg("-1").succeeds();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,3 +154,50 @@ fn test_more_error_on_multiple_files() {
|
|||
.stderr_contains("file3");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_more_pattern_found() {
|
||||
if std::io::stdout().is_terminal() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let file = "test_file";
|
||||
|
||||
at.write(file, "line1\nline2");
|
||||
|
||||
// output only the second line "line2"
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-P")
|
||||
.arg("line2")
|
||||
.arg(file)
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_does_not_contain("line1")
|
||||
.stdout_contains("line2");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_more_pattern_not_found() {
|
||||
if std::io::stdout().is_terminal() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let file = "test_file";
|
||||
|
||||
let file_content = "line1\nline2";
|
||||
at.write(file, file_content);
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-P")
|
||||
.arg("something")
|
||||
.arg(file)
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_contains("Pattern not found")
|
||||
.stdout_contains("line1")
|
||||
.stdout_contains("line2");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue