From 95871a82a4205574436efee9a7b7a940635d78da Mon Sep 17 00:00:00 2001 From: dylni <46035563+dylni@users.noreply.github.com> Date: Sun, 28 Jul 2024 15:41:44 -0400 Subject: [PATCH] Add more tests --- tests/windows.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/windows.rs b/tests/windows.rs index f69ae37..a2ab290 100644 --- a/tests/windows.rs +++ b/tests/windows.rs @@ -131,6 +131,40 @@ fn test_edge_cases() { // test!(r"/??/X:", SAME, r"\??\X:"); } +#[test] +fn test_short() { + #[track_caller] + fn test(short_path: &str, long_path: &str) { + let short_path = Path::new(short_path); + let long_path = Path::new(long_path); + common::assert_eq(long_path, short_path.normalize()); + assert_ne!( + long_path, + short_path + .normalize_virtually() + .expect("failed to normalize existing path"), + ); + } + + test(r"C:\DOCUME~1", r"C:\Documents and Settings"); + test(r"C:\PROGRA~1", r"C:\Program Files"); + test(r"C:\PROGRA~2", r"C:\Program Files (x86)"); +} + +#[test] +fn test_existing() { + #[track_caller] + fn test(path: &str) { + let path = Path::new(path); + assert!(path.metadata().is_ok()); + common::assert_eq(path, path.normalize()); + } + + test(r"C:\Documents and Settings"); + test(r"\\localhost\C$\Documents and Settings"); + test(r"\\?\C:\Documents and Settings"); +} + // https://github.com/dylni/normpath/issues/5 #[test] fn test_windows_bug() -> io::Result<()> {