#[test]
fn test_fix_long_path() {
let very_long = format!("l{}ng", "o".repeat(248));
struct TestCase(&'static str, &'static str);
let test_cases = &[
TestCase(r"C:\short.txt", r"C:\short.txt"),
TestCase(r"C:\", r"C:\"),
TestCase(r"C:", r"C:"),
TestCase(r"C:\long\foo.txt", r"\\?\C:\long\foo.txt"),
TestCase(r"C:/long/foo.txt", r"\\?\C:\long\foo.txt"),
TestCase(r"C:\long\foo\\bar\.\baz\\", r"\\?\C:\long\foo\bar\baz"),
TestCase(r"\\unc\path", r"\\unc\path"),
TestCase(r"long.txt", r"long.txt"),
TestCase(r"C:long.txt", r"C:long.txt"),
TestCase(r"c:\long\..\bar\baz", r"c:\long\..\bar\baz"),
TestCase(r"\\?\c:\long\foo.txt", r"\\?\c:\long\foo.txt"),
TestCase(r"\\?\c:\long/foo.txt", r"\\?\c:\long/foo.txt"),
];
for (i, test) in test_cases.iter().enumerate() {
let input = test.0.to_string().replace("long", &very_long);
let want = test.1.to_string().replace("long", &very_long);
let got = super::fix_long_path(&input);
assert_eq!(
want, got,
"#{} fix_long_path({:?}) = {:?}; want {:?}",
i, input, got, want
);
}
}