1
Fork 0
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:
jfinkels 2025-02-21 08:41:15 -05:00 committed by GitHub
parent d065e172f7
commit 4acc59d075
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 46 additions and 4 deletions

View file

@ -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();
}