mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
test: add < and > operators for string comparison (#7315)
* test: add < and > operators for string comparison Fixes #7254. * Add more tests for string inequality * Use match in place of if/elseif block Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com> * Change test name to specify lt/gt operator --------- Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
This commit is contained in:
parent
d065e172f7
commit
4acc59d075
3 changed files with 46 additions and 4 deletions
|
@ -991,3 +991,40 @@ fn test_missing_argument_after() {
|
|||
"test: missing argument after 'foo'"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_string_lt_gt_operator() {
|
||||
let items = [
|
||||
("a", "b"),
|
||||
("a", "aa"),
|
||||
("a", "a "),
|
||||
("a", "a b"),
|
||||
("", "b"),
|
||||
("a", "ä"),
|
||||
];
|
||||
for (left, right) in items {
|
||||
new_ucmd!().args(&[left, "<", right]).succeeds().no_output();
|
||||
new_ucmd!()
|
||||
.args(&[right, "<", left])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.no_output();
|
||||
|
||||
new_ucmd!().args(&[right, ">", left]).succeeds().no_output();
|
||||
new_ucmd!()
|
||||
.args(&[left, ">", right])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.no_output();
|
||||
}
|
||||
new_ucmd!()
|
||||
.args(&["", "<", ""])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.no_output();
|
||||
new_ucmd!()
|
||||
.args(&["", ">", ""])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.no_output();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue