mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-02 22:17:45 +00:00
Merge pull request #2432 from dezgeg/test-bracket-syntax
test: Implement [ expr ] syntax
This commit is contained in:
commit
115eb5eb52
3 changed files with 68 additions and 3 deletions
|
@ -690,3 +690,31 @@ fn test_or_as_filename() {
|
|||
fn test_string_length_and_nothing() {
|
||||
new_ucmd!().args(&["-n", "a", "-a"]).run().status_code(2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bracket_syntax_success() {
|
||||
let scenario = TestScenario::new("[");
|
||||
let mut ucmd = scenario.ucmd();
|
||||
|
||||
ucmd.args(&["1", "-eq", "1", "]"]).succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bracket_syntax_failure() {
|
||||
let scenario = TestScenario::new("[");
|
||||
let mut ucmd = scenario.ucmd();
|
||||
|
||||
ucmd.args(&["1", "-eq", "2", "]"]).run().status_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bracket_syntax_missing_right_bracket() {
|
||||
let scenario = TestScenario::new("[");
|
||||
let mut ucmd = scenario.ucmd();
|
||||
|
||||
// Missing closing bracket takes precedence over other possible errors.
|
||||
ucmd.args(&["1", "-eq"])
|
||||
.run()
|
||||
.status_code(2)
|
||||
.stderr_is("[: missing ']'");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue