From 6e96154d8649163df7a6fae0c55539108c14e148 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Fri, 3 Apr 2020 19:09:35 +0200 Subject: [PATCH] Add tests for strip_current_dir --- src/filesystem.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/filesystem.rs b/src/filesystem.rs index 1c395fc..8b0d593 100644 --- a/src/filesystem.rs +++ b/src/filesystem.rs @@ -92,3 +92,24 @@ pub fn strip_current_dir(pathbuf: &PathBuf) -> &Path { } iter.as_path() } + +#[cfg(test)] +mod tests { + #[test] + fn strip_current_dir_basic() { + use std::path::{Path, PathBuf}; + + use super::strip_current_dir; + + assert_eq!(strip_current_dir(&PathBuf::from("./foo")), Path::new("foo")); + assert_eq!(strip_current_dir(&PathBuf::from("foo")), Path::new("foo")); + assert_eq!( + strip_current_dir(&PathBuf::from("./foo/bar/baz")), + Path::new("foo/bar/baz") + ); + assert_eq!( + strip_current_dir(&PathBuf::from("foo/bar/baz")), + Path::new("foo/bar/baz") + ); + } +}