2022-04-15 16:58:31 +00:00
|
|
|
#[test]
|
|
|
|
fn insert() {
|
2022-04-15 18:48:58 +00:00
|
|
|
let mut raw = clap_lex::RawArgs::new(["bin", "a", "b", "c"]);
|
2022-04-15 16:58:31 +00:00
|
|
|
let mut cursor = raw.cursor();
|
|
|
|
|
|
|
|
assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("bin")));
|
|
|
|
assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("a")));
|
2022-11-24 13:54:25 +00:00
|
|
|
raw.insert(&cursor, ["1", "2", "3"]);
|
2022-04-15 16:58:31 +00:00
|
|
|
assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("1")));
|
|
|
|
assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("2")));
|
|
|
|
assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("3")));
|
|
|
|
assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("b")));
|
|
|
|
assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("c")));
|
|
|
|
|
|
|
|
let mut cursor = raw.cursor();
|
|
|
|
let rest = raw
|
|
|
|
.remaining(&mut cursor)
|
|
|
|
.map(|s| s.to_string_lossy())
|
|
|
|
.collect::<Vec<_>>();
|
|
|
|
assert_eq!(rest, vec!["bin", "a", "1", "2", "3", "b", "c"]);
|
|
|
|
}
|