mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Tests ~ improve portability of tests for 'Fix ~ improve portability of path manipulation'
This commit is contained in:
+41
-5
@@ -265,23 +265,59 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_simplify_dir_rm_subdir() {
|
fn test_simplify_dir_rm_subdir() {
|
||||||
let mut correct = HashSet::new();
|
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);
|
assert_eq!(simplify_dir_names(vec!["a/b", "a/b/c", "a/b/d/f"]), correct);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_simplify_dir_duplicates() {
|
fn test_simplify_dir_duplicates() {
|
||||||
let mut correct = HashSet::new();
|
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());
|
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]
|
#[test]
|
||||||
fn test_simplify_dir_rm_subdir_and_not_substrings() {
|
fn test_simplify_dir_rm_subdir_and_not_substrings() {
|
||||||
let mut correct = HashSet::new();
|
let mut correct = HashSet::new();
|
||||||
correct.insert("b".to_string());
|
correct.insert("b".to_string());
|
||||||
correct.insert("c/a/b".to_string());
|
correct.insert(
|
||||||
correct.insert("a/b".to_string());
|
["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);
|
assert_eq!(simplify_dir_names(vec!["a/b", "c/a/b/", "b"]), correct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user