Skip to content

Commit

Permalink
Use as_os_str to compare exact paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed Mar 5, 2022
1 parent 27f6d2c commit 3009eec
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions library/std/src/path/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1731,11 +1731,11 @@ fn test_windows_absolute() {
let relative = r"a\b";
let mut expected = crate::env::current_dir().unwrap();
expected.push(relative);
assert_eq!(absolute(relative).unwrap(), expected);
assert_eq!(absolute(relative).unwrap().as_os_str(), expected.as_os_str());

macro_rules! unchanged(
($path:expr) => {
assert_eq!(absolute($path).unwrap(), Path::new($path));
assert_eq!(absolute($path).unwrap().as_os_str(), Path::new($path).as_os_str());
}
);

Expand All @@ -1751,7 +1751,10 @@ fn test_windows_absolute() {
// Verbatim paths are always unchanged, no matter what.
unchanged!(r"\\?\path.\to/file..");

assert_eq!(absolute(r"C:\path..\to.\file.").unwrap(), Path::new(r"C:\path..\to\file"));
assert_eq!(
absolute(r"C:\path..\to.\file.").unwrap().as_os_str(),
Path::new(r"C:\path..\to\file").as_os_str()
);
assert_eq!(absolute(r"COM1").unwrap().as_os_str(), Path::new(r"\\.\COM1").as_os_str());
}

Expand Down

0 comments on commit 3009eec

Please sign in to comment.