We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c3bb33c commit 6a96814Copy full SHA for 6a96814
src/lib.rs
@@ -94,3 +94,24 @@ mod win32 {
94
Some(PathBuf::from(path))
95
}
96
97
+
98
+#[cfg(test)]
99
+mod tests {
100
+ use super::*;
101
102
+ #[test]
103
+ fn home() {
104
+ let home = home_dir().unwrap();
105
+ assert!(home.is_dir());
106
107
+ if let Ok(env_home) = std::env::var("HOME") {
108
+ // If `HOME` is set, `home_dir` took the value from it.
109
+ let env_home = PathBuf::from(env_home);
110
+ assert_eq!(home, env_home);
111
112
+ // With `HOME` unset, `home_dir` should still return the same value.
113
+ std::env::remove_var("HOME");
114
+ assert_eq!(home_dir().unwrap(), env_home);
115
+ }
116
117
+}
0 commit comments