Tests ~ improve portability of tests for 'Fix ~ improve portability of path manipulation'

This commit is contained in:
Roy Ivy III
2020-01-23 16:12:57 -06:00
parent 7a38a26593
commit e126a01096

View File

@@ -265,23 +265,59 @@ mod tests {
#[test]
fn test_simplify_dir_rm_subdir() {
let mut correct = HashSet::new();
correct.insert("a/b".to_string());
correct.insert(
["a", "b"]
.iter()
.collect::<std::path::PathBuf>()
.to_string_lossy()
.to_string(),
);
assert_eq!(simplify_dir_names(vec!["a/b", "a/b/c", "a/b/d/f"]), correct);
}
#[test]
fn test_simplify_dir_duplicates() {
let mut correct = HashSet::new();
correct.insert("a/b".to_string());
correct.insert(
["a", "b"]
.iter()
.collect::<std::path::PathBuf>()
.to_string_lossy()
.to_string(),
);
correct.insert("c".to_string());
assert_eq!(simplify_dir_names(vec!["a/b", "a/b//", "c", "c/"]), correct);
assert_eq!(
simplify_dir_names(vec![
"a/b",
"a/b//",
"a/././b///",
"c",
"c/",
"c/.",
"c/././",
"c/././."
]),
correct
);
}
#[test]
fn test_simplify_dir_rm_subdir_and_not_substrings() {
let mut correct = HashSet::new();
correct.insert("b".to_string());
correct.insert("c/a/b".to_string());
correct.insert("a/b".to_string());
correct.insert(
["c", "a", "b"]
.iter()
.collect::<std::path::PathBuf>()
.to_string_lossy()
.to_string(),
);
correct.insert(
["a", "b"]
.iter()
.collect::<std::path::PathBuf>()
.to_string_lossy()
.to_string(),
);
assert_eq!(simplify_dir_names(vec!["a/b", "c/a/b/", "b"]), correct);
}