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

test/expr: add 'index' operator tests

This commit is contained in:
Roy Ivy III 2022-12-27 20:31:39 -06:00
parent f3285d9662
commit 8e7dbb0bf6

View file

@ -97,6 +97,31 @@ fn test_and() {
new_ucmd!().args(&["", "&", "1"]).run().stdout_is("0\n"); new_ucmd!().args(&["", "&", "1"]).run().stdout_is("0\n");
} }
#[test]
fn test_index() {
new_ucmd!()
.args(&["index", "αbcdef", "x"])
.fails()
.status_code(1)
.stdout_only("0\n");
new_ucmd!()
.args(&["index", "αbcdef", "α"])
.succeeds()
.stdout_only("1\n");
new_ucmd!()
.args(&["index", "αbcdef", "fb"])
.succeeds()
.stdout_only("2\n");
new_ucmd!()
.args(&["index", "αbcdef", "f"])
.succeeds()
.stdout_only("6\n");
new_ucmd!()
.args(&["index", "αbcdef_f", "f"])
.succeeds()
.stdout_only("6\n");
}
#[test] #[test]
fn test_length_fail() { fn test_length_fail() {
new_ucmd!().args(&["length", "αbcdef", "1"]).fails(); new_ucmd!().args(&["length", "αbcdef", "1"]).fails();