use super::{canon_path_key, within};
use std::path::Path;
#[test]
fn within_is_component_wise_not_string_prefix() {
let root = canon_path_key(Path::new("/base/root"));
let sib = canon_path_key(Path::new("/base/rootsibling/x"));
let child = canon_path_key(Path::new("/base/root/x"));
assert!(within(&root, &child));
assert!(!within(&root, &sib));
assert!(within(&root, &root));
}
#[cfg(windows)]
#[test]
fn windows_case_only_siblings_are_not_contained() {
let foo_root = canon_path_key(Path::new(r"C:\base\Foo"));
let foo_lower = canon_path_key(Path::new(r"C:\base\foo\secret"));
assert_ne!(foo_root, canon_path_key(Path::new(r"C:\base\foo")));
assert!(
!within(&foo_root, &foo_lower),
"case-only sibling escaped confinement: fold must not be applied"
);
let foo_child = canon_path_key(Path::new(r"C:\base\Foo\secret"));
assert!(within(&foo_root, &foo_child));
}