More OsSplit testing

This commit is contained in:
Félix Saparelli 2022-01-18 22:53:24 +13:00
parent 0334b9c9fa
commit 881e8f4047
1 changed files with 17 additions and 0 deletions

View File

@ -188,6 +188,8 @@ impl Iterator for OsSplit {
#[test]
fn os_split_none() {
let os = OsString::from("");
assert_eq!(os.split(b',').collect::<Vec<OsString>>(), Vec::<OsString>::new());
let mut split = os.split(b',');
assert_eq!(split.next(), None);
}
@ -196,6 +198,8 @@ fn os_split_none() {
#[test]
fn os_split_one() {
let os = OsString::from("abc");
assert_eq!(os.split(b',').collect::<Vec<OsString>>(), vec![OsString::from("abc")]);
let mut split = os.split(b',');
assert_eq!(split.next(), Some(OsString::from("abc")));
assert_eq!(split.next(), None);
@ -205,6 +209,12 @@ fn os_split_one() {
#[test]
fn os_split_multi() {
let os = OsString::from("a,b,c");
assert_eq!(os.split(b',').collect::<Vec<OsString>>(), vec![
OsString::from("a"),
OsString::from("b"),
OsString::from("c"),
]);
let mut split = os.split(b',');
assert_eq!(split.next(), Some(OsString::from("a")));
assert_eq!(split.next(), Some(OsString::from("b")));
@ -216,6 +226,13 @@ fn os_split_multi() {
#[test]
fn os_split_leading() {
let os = OsString::from(",a,b,c");
assert_eq!(os.split(b',').collect::<Vec<OsString>>(), vec![
OsString::from(""),
OsString::from("a"),
OsString::from("b"),
OsString::from("c"),
]);
let mut split = os.split(b',');
assert_eq!(split.next(), Some(OsString::from("")));
assert_eq!(split.next(), Some(OsString::from("a")));