Skip to content

Commit 3324a14

Browse files
committed
Tests
1 parent 92ae54c commit 3324a14

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/libstd/path.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,16 @@ impl Path {
18631863

18641864
/// Checks if the path buffer is empty. On Windows, it will return false if the inner string is
18651865
/// invalid unicode. On Unix, this is a no-op.
1866+
///
1867+
/// # Examples
1868+
///
1869+
/// ```
1870+
/// use std::path::Path;
1871+
///
1872+
/// let path = Path::new("/tmp/foo.rs");
1873+
///
1874+
/// assert!(!path.is_empty());
1875+
/// ```
18661876
#[unstable(feature = "path_extras", reason = "recently added", issue = "30259")]
18671877
pub fn is_empty(&self) -> bool {
18681878
if let Some(b) = self.inner.to_bytes() {
@@ -3200,6 +3210,17 @@ mod tests {
32003210
}
32013211
}
32023212

3213+
#[test]
3214+
pub fn is_empty() {
3215+
let path = Path::new("/tmp/foo.rs");
3216+
let mut path_buf = PathBuf::new();
3217+
3218+
assert!(!path.is_empty());
3219+
assert!(path_buf.is_empty());
3220+
path_buf.push("catsarecute");
3221+
assert!(!path_buf.is_empty());
3222+
}
3223+
32033224
#[test]
32043225
pub fn test_set_extension() {
32053226
macro_rules! tfe(

0 commit comments

Comments
 (0)