use rust_tree::rust_tree::fromfile::{parse_simple_paths, parse_tar_simple_line};
#[test]
fn test_path_normalization_windows_backslashes() {
let windows_paths = vec![
"src\\main.rs".to_string(),
"test\\path\\file.txt".to_string(),
];
let entries = parse_simple_paths(windows_paths);
for entry in &entries {
assert!(
!entry.path.contains('\\'),
"Path contains backslash: {}",
entry.path
);
}
let has_normalized_main = entries.iter().any(|e| e.path == "src/main.rs");
let has_normalized_test = entries.iter().any(|e| e.path == "test/path/file.txt");
assert!(has_normalized_main);
assert!(has_normalized_test);
}
#[test]
fn test_path_normalization_windows_drive_letters() {
let c_drive_path = "C:/path/file.txt";
let entry = parse_tar_simple_line(c_drive_path).unwrap();
assert_eq!(entry.path, "C/path/file.txt");
let d_drive_path = "D:\\Users\\test";
let entry = parse_tar_simple_line(d_drive_path).unwrap();
assert_eq!(entry.path, "D/Users/test");
}
#[test]
fn test_path_normalization_dot_slash_prefix() {
let paths = vec!["./src/main.rs".to_string(), "./file.txt".to_string()];
let entries = parse_simple_paths(paths);
let has_src_main = entries.iter().any(|e| e.path == "src/main.rs");
let has_file = entries.iter().any(|e| e.path == "file.txt");
assert!(has_src_main);
assert!(has_file);
}
#[test]
fn test_path_normalization_unchanged_paths() {
let normal_paths = vec![
"src/main.rs".to_string(),
"file.txt".to_string(),
"".to_string(),
];
let entries = parse_simple_paths(normal_paths);
let has_src_main = entries.iter().any(|e| e.path == "src/main.rs");
let has_file = entries.iter().any(|e| e.path == "file.txt");
assert!(has_src_main);
assert!(has_file);
}
#[test]
fn test_path_normalization_edge_cases() {
let edge_case_path = "C_file.txt";
let entry = parse_tar_simple_line(edge_case_path).unwrap();
assert_eq!(entry.path, "C_file.txt"); }