nu_path/
assert_path_eq.rs#[macro_export]
macro_rules! assert_path_eq {
($left:expr, $right:expr $(,)?) => {
assert_eq!(
AsRef::<Path>::as_ref(&$left).to_str().unwrap(),
AsRef::<Path>::as_ref(&$right).to_str().unwrap()
)
};
}
#[macro_export]
macro_rules! assert_path_ne {
($left:expr, $right:expr $(,)?) => {
assert_ne!(
AsRef::<Path>::as_ref(&$left).to_str().unwrap(),
AsRef::<Path>::as_ref(&$right).to_str().unwrap()
)
};
}
#[cfg(test)]
mod test {
use std::path::{Path, PathBuf};
#[test]
fn assert_path_eq_works() {
assert_path_eq!(PathBuf::from("/foo/bar"), Path::new("/foo/bar"));
assert_path_eq!(PathBuf::from("/foo/bar"), String::from("/foo/bar"));
assert_path_eq!(PathBuf::from("/foo/bar"), "/foo/bar");
assert_path_eq!(Path::new("/foo/bar"), String::from("/foo/bar"));
assert_path_eq!(Path::new("/foo/bar"), "/foo/bar");
assert_path_eq!(Path::new(r"\foo\bar"), r"\foo\bar");
assert_path_ne!(PathBuf::from("/foo/bar/."), Path::new("/foo/bar"));
assert_path_ne!(PathBuf::from("/foo/bar/."), String::from("/foo/bar"));
assert_path_ne!(PathBuf::from("/foo/bar/."), "/foo/bar");
assert_path_ne!(Path::new("/foo/./bar"), String::from("/foo/bar"));
assert_path_ne!(Path::new("/foo/./bar"), "/foo/bar");
assert_path_ne!(Path::new(r"\foo\bar"), r"/foo/bar");
assert_path_ne!(Path::new(r"/foo/bar"), r"\foo\bar");
}
}