Skip to content

Commit 5cdd3a4

Browse files
SAY-5sylvestre
authored andcommitted
diffutils: assert width-like operands are kept as filenames in tests
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
1 parent ea7230e commit 5cdd3a4

1 file changed

Lines changed: 23 additions & 7 deletions

File tree

‎src/params.rs‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -830,21 +830,37 @@ mod tests {
830830
)
831831
);
832832
}
833+
#[test]
834+
fn width_suffix_is_an_operand() {
835+
assert_eq!(
836+
Ok(Params {
837+
executable: os("diff"),
838+
from: os("xyz--width=5"),
839+
to: os("foo"),
840+
..Default::default()
841+
}),
842+
parse_params(
843+
[os("diff"), os("xyz--width=5"), os("foo")]
844+
.iter()
845+
.cloned()
846+
.peekable()
847+
)
848+
);
849+
}
833850
#[cfg(unix)]
834851
#[test]
835852
fn width_non_utf8_is_not_an_option() {
836853
use std::os::unix::ffi::OsStringExt;
837-
// A non-UTF-8 argument whose lossy form ends in `--width=N` must be
838-
// treated as an operand, not parsed as the width option (which used to
839-
// panic in `into_string().unwrap()`).
854+
// used to panic in into_string().unwrap()
840855
let bad = OsString::from_vec(b"\xff--width=5".to_vec());
841-
assert!(parse_params(
842-
[os("diff"), bad, os("foo"), os("bar")]
856+
let params = parse_params(
857+
[os("diff"), bad.clone(), os("foo")]
843858
.iter()
844859
.cloned()
845-
.peekable()
860+
.peekable(),
846861
)
847-
.is_err());
862+
.unwrap();
863+
assert_eq!(params.from, bad);
848864
}
849865
#[test]
850866
fn double_dash() {

0 commit comments

Comments
 (0)