Add windows + single quote tests

This commit is contained in:
Daniel Edrisian
2025-08-21 15:21:38 -07:00
parent 2aedf93573
commit 422556ba5b

View File

@@ -56,6 +56,21 @@ mod tests {
assert_eq!(result, PathBuf::from("/home/user/My File.png"));
}
#[test]
fn normalize_single_quoted_unix_path() {
let input = "'/home/user/My File.png'";
let result = normalize_pasted_path(input).expect("should trim single quotes via shlex");
assert_eq!(result, PathBuf::from("/home/user/My File.png"));
}
#[test]
fn normalize_single_quoted_windows_path() {
let input = r"'C:\Users\Alice\My File.jpeg'";
let result =
normalize_pasted_path(input).expect("should trim single quotes on windows path");
assert_eq!(result, PathBuf::from(r"C:\Users\Alice\My File.jpeg"));
}
#[test]
fn img_format_label_png_jpeg_unknown() {
assert_eq!(get_img_format_label(PathBuf::from("/a/b/c.PNG")), "PNG");
@@ -64,4 +79,14 @@ mod tests {
assert_eq!(get_img_format_label(PathBuf::from("/a/b/c")), "IMG");
assert_eq!(get_img_format_label(PathBuf::from("/a/b/c.webp")), "IMG");
}
#[test]
fn img_format_label_with_windows_style_paths() {
assert_eq!(get_img_format_label(PathBuf::from(r"C:\a\b\c.PNG")), "PNG");
assert_eq!(
get_img_format_label(PathBuf::from(r"C:\a\b\c.jpeg")),
"JPEG"
);
assert_eq!(get_img_format_label(PathBuf::from(r"C:\a\b\noext")), "IMG");
}
}