| 1 | use zipelo_ui_memory_app::archive_path::windows_path; |
| 2 | |
| 3 | #[test] |
| 4 | fn ordinary_verbatim_drives_are_converted_without_changing_components() { |
| 5 | for (input, expected) in [ |
| 6 | (r"\\?\C:\Users\사용자\one.txt", r"C:\Users\사용자\one.txt"), |
| 7 | (r"\\?\C:\", r"C:\"), |
| 8 | (r"D:\one.txt", r"D:\one.txt"), |
| 9 | ] { |
| 10 | assert_eq!(windows_path(input), expected); |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | #[test] |
| 15 | fn unc_devices_and_ambiguous_components_remain_blocked() { |
| 16 | for input in [ |
| 17 | r"\\?\UNC\server\share\one.txt", |
| 18 | r"\\server\share\one.txt", |
| 19 | r"\\.\C:\one.txt", |
| 20 | r"\\?\GLOBALROOT\Device\one", |
| 21 | r"\\?\C:\a\..\one", |
| 22 | r"\\?\C:\a\.\one", |
| 23 | r"\\?\C:\a\name.", |
| 24 | r"\\?\C:\a\name ", |
| 25 | r"\\?\C:\a\NUL", |
| 26 | r"\\?\C:\a\one:stream", |
| 27 | r"\\?\C:\a\\one", |
| 28 | r"\\?\C:\a/one", |
| 29 | r"\\?\C:one", |
| 30 | ] { |
| 31 | assert_eq!(windows_path(input), input); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | #[test] |
| 36 | fn creation_messages_use_save_vocabulary_and_preserve_warnings() { |
| 37 | use zipelo_ui_memory_app::archive_present::*; |
| 38 | for text in [ |
| 39 | UNCERTAIN, |
| 40 | PARTIAL, |
| 41 | LEFTOVERS, |
| 42 | SYNC_FAILED, |
| 43 | CLEANUP_WARNING, |
| 44 | UNCONFIRMED_FINISH, |
| 45 | error_text(zipelo_ui_memory_app::archive_ui::ErrorCode::InvalidRequest), |
| 46 | ] { |
| 47 | assert_eq!(operation_text(text, false), text); |
| 48 | assert!(!operation_text(text, true).contains("풀 위치")); |
| 49 | } |
| 50 | assert!(operation_text(UNCERTAIN, true).contains("확인하지 못했습니다")); |
| 51 | } |
| 52 | |
| 53 | #[cfg(windows)] |
| 54 | #[test] |
| 55 | fn windows_native_contract_accepts_drives_and_still_rejects_unc() { |
| 56 | use std::path::Path; |
| 57 | use worker_protocol::protocol::NativePath; |
| 58 | use zipelo_ui_memory_app::archive_path::worker_path; |
| 59 | let ordinary = worker_path(Path::new(r"\\?\C:\Users\one.txt")); |
| 60 | assert_eq!( |
| 61 | NativePath::from_path(&ordinary).to_path().unwrap(), |
| 62 | Path::new(r"C:\Users\one.txt") |
| 63 | ); |
| 64 | for text in [ |
| 65 | r"\\?\UNC\server\share\one.txt", |
| 66 | r"\\server\share\one.txt", |
| 67 | r"\\?\C:\a\..\one", |
| 68 | ] { |
| 69 | assert!( |
| 70 | NativePath::from_path(&worker_path(Path::new(text))) |
| 71 | .to_path() |
| 72 | .is_err() |
| 73 | ); |
| 74 | } |
| 75 | } |