mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-29 22:51:33 +02:00
Further windows fix to OsSplit
This commit is contained in:
parent
783da395bb
commit
7f092ca4b7
@ -176,18 +176,24 @@ impl Iterator for OsSplit {
|
|||||||
|
|
||||||
let res = OsString::from_wide(&cur);
|
let res = OsString::from_wide(&cur);
|
||||||
self.pos = cur.len() + 1;
|
self.pos = cur.len() + 1;
|
||||||
Some(res)
|
if res.is_empty() && self.pos >= self.os.len() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(res)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)] #[test]
|
#[cfg(test)]
|
||||||
|
#[test]
|
||||||
fn os_split_none() {
|
fn os_split_none() {
|
||||||
let os = OsString::from("");
|
let os = OsString::from("");
|
||||||
let mut split = os.split(b',');
|
let mut split = os.split(b',');
|
||||||
assert_eq!(split.next(), None);
|
assert_eq!(split.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)] #[test]
|
#[cfg(test)]
|
||||||
|
#[test]
|
||||||
fn os_split_one() {
|
fn os_split_one() {
|
||||||
let os = OsString::from("abc");
|
let os = OsString::from("abc");
|
||||||
let mut split = os.split(b',');
|
let mut split = os.split(b',');
|
||||||
@ -195,7 +201,8 @@ fn os_split_one() {
|
|||||||
assert_eq!(split.next(), None);
|
assert_eq!(split.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)] #[test]
|
#[cfg(test)]
|
||||||
|
#[test]
|
||||||
fn os_split_multi() {
|
fn os_split_multi() {
|
||||||
let os = OsString::from("a,b,c");
|
let os = OsString::from("a,b,c");
|
||||||
let mut split = os.split(b',');
|
let mut split = os.split(b',');
|
||||||
@ -204,3 +211,15 @@ fn os_split_multi() {
|
|||||||
assert_eq!(split.next(), Some(OsString::from("c")));
|
assert_eq!(split.next(), Some(OsString::from("c")));
|
||||||
assert_eq!(split.next(), None);
|
assert_eq!(split.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[test]
|
||||||
|
fn os_split_leading() {
|
||||||
|
let os = OsString::from(",a,b,c");
|
||||||
|
let mut split = os.split(b',');
|
||||||
|
assert_eq!(split.next(), Some(OsString::from("")));
|
||||||
|
assert_eq!(split.next(), Some(OsString::from("a")));
|
||||||
|
assert_eq!(split.next(), Some(OsString::from("b")));
|
||||||
|
assert_eq!(split.next(), Some(OsString::from("c")));
|
||||||
|
assert_eq!(split.next(), None);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user