From 422556ba5bfb721dc4868cd7f034c305117c6eac Mon Sep 17 00:00:00 2001 From: Daniel Edrisian Date: Thu, 21 Aug 2025 15:21:38 -0700 Subject: [PATCH] Add windows + single quote tests --- codex-rs/tui/src/bottom_pane/string_utils.rs | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/codex-rs/tui/src/bottom_pane/string_utils.rs b/codex-rs/tui/src/bottom_pane/string_utils.rs index 4c25b75ccf..86b56c2d78 100644 --- a/codex-rs/tui/src/bottom_pane/string_utils.rs +++ b/codex-rs/tui/src/bottom_pane/string_utils.rs @@ -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"); + } }