From 881e8f404702baeeed09305a574ebf243a198a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Tue, 18 Jan 2022 22:53:24 +1300 Subject: [PATCH] More OsSplit testing --- cli/src/filterer/globset.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cli/src/filterer/globset.rs b/cli/src/filterer/globset.rs index 3ccbd0f..cf3a359 100644 --- a/cli/src/filterer/globset.rs +++ b/cli/src/filterer/globset.rs @@ -188,6 +188,8 @@ impl Iterator for OsSplit { #[test] fn os_split_none() { let os = OsString::from(""); + assert_eq!(os.split(b',').collect::>(), Vec::::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::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::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::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")));