about summary refs log tree commit diff
path: root/library/std/src/sys/windows/path
diff options
context:
space:
mode:
authordylni <46035563+dylni@users.noreply.github.com>2022-03-19 10:30:34 -0400
committerdylni <46035563+dylni@users.noreply.github.com>2022-04-17 01:23:46 -0400
commite87082293e11a2f9c6d38bcd9896e8742e110ef8 (patch)
treef0c2a82bf1bffaabc8b3798208b1417669f1800a /library/std/src/sys/windows/path
parent2c28b0eaf9843ec0f493fca2dba506fe4d9174fb (diff)
downloadrust-e87082293e11a2f9c6d38bcd9896e8742e110ef8.tar.gz
rust-e87082293e11a2f9c6d38bcd9896e8742e110ef8.zip
Improve Windows path prefix parsing
Diffstat (limited to 'library/std/src/sys/windows/path')
-rw-r--r--library/std/src/sys/windows/path/tests.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/library/std/src/sys/windows/path/tests.rs b/library/std/src/sys/windows/path/tests.rs
index 425c2011b32..8656b04e4f4 100644
--- a/library/std/src/sys/windows/path/tests.rs
+++ b/library/std/src/sys/windows/path/tests.rs
@@ -94,3 +94,23 @@ fn verbatim() {
     // A path that contains null is not a valid path.
     assert!(maybe_verbatim(Path::new("\0")).is_err());
 }
+
+fn parse_prefix(path: &str) -> Option<Prefix<'_>> {
+    super::parse_prefix(OsStr::new(path))
+}
+
+#[test]
+fn test_parse_prefix_verbatim() {
+    let prefix = Some(Prefix::VerbatimDisk(b'C'));
+    assert_eq!(prefix, parse_prefix(r"\\?\C:/windows/system32/notepad.exe"));
+    assert_eq!(prefix, parse_prefix(r"\\?\C:\windows\system32\notepad.exe"));
+}
+
+#[test]
+fn test_parse_prefix_verbatim_device() {
+    let prefix = Some(Prefix::UNC(OsStr::new("?"), OsStr::new("C:")));
+    assert_eq!(prefix, parse_prefix(r"//?/C:/windows/system32/notepad.exe"));
+    assert_eq!(prefix, parse_prefix(r"//?/C:\windows\system32\notepad.exe"));
+    assert_eq!(prefix, parse_prefix(r"/\?\C:\windows\system32\notepad.exe"));
+    assert_eq!(prefix, parse_prefix(r"\\?/C:\windows\system32\notepad.exe"));
+}