diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index 3a753aa1b..a286f2cf4 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -97,6 +97,31 @@ fn test_and() { 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] fn test_length_fail() { new_ucmd!().args(&["length", "αbcdef", "1"]).fails();