about summary refs log tree commit diff
path: root/library/std/src/path
diff options
context:
space:
mode:
authorChris Denton <christophersdenton@gmail.com>2022-03-05 17:57:12 +0000
committerChris Denton <christophersdenton@gmail.com>2022-03-05 17:57:12 +0000
commite8b7371a237451cdc73547b27311fd8d5078521f (patch)
treeeee7817bddb94afc2db6716c573423ee9c346faa /library/std/src/path
parentc8a49fc90281d9a3227a547b5bac8e01d17325be (diff)
downloadrust-e8b7371a237451cdc73547b27311fd8d5078521f.tar.gz
rust-e8b7371a237451cdc73547b27311fd8d5078521f.zip
Unix `path::absolute`: Fix leading "." component
Testing leading `.` and `..` components were missing from the unix tests.
Diffstat (limited to 'library/std/src/path')
-rw-r--r--library/std/src/path/tests.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/path/tests.rs b/library/std/src/path/tests.rs
index 8e51433094a..435e84f8cef 100644
--- a/library/std/src/path/tests.rs
+++ b/library/std/src/path/tests.rs
@@ -1719,6 +1719,11 @@ fn test_unix_absolute() {
     assert_eq!(absolute("///a/b/c").unwrap(), Path::new("/a/b/c"));
     assert_eq!(absolute("/a/b/c/").unwrap(), Path::new("/a/b/c/"));
     assert_eq!(absolute("/a/./b/../c/.././..").unwrap(), Path::new("/a/b/../c/../.."));
+
+    // Test leading `.` and `..` components
+    let curdir = crate::env::current_dir().unwrap();
+    assert_eq!(absolute("./a").unwrap().as_os_str(), curdir.join("a").as_os_str());
+    assert_eq!(absolute("../a").unwrap().as_os_str(), curdir.join("../a").as_os_str()); // return /pwd/../a
 }
 
 #[test]