testsuite: Add a test for listing the root directory...
...and don't treat Path("/") like Path("").
This commit is contained in:
parent
196851c4c9
commit
a243ea39c3
@ -675,7 +675,7 @@ pub fn mkdir_recursive(p: &Path, mode: c_int) -> bool {
|
||||
/// Lists the contents of a directory
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
pub fn list_dir(p: &Path) -> ~[~str] {
|
||||
if p.components.is_empty() {
|
||||
if p.components.is_empty() && !p.is_absolute() {
|
||||
// Not sure what the right behavior is here, but this
|
||||
// prevents a bounds check failure later
|
||||
return ~[];
|
||||
@ -1607,6 +1607,20 @@ fn list_dir_empty_path() {
|
||||
assert!(dirs.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
fn list_dir_root() {
|
||||
let dirs = os::list_dir(&Path("/"));
|
||||
assert!(dirs.len() > 1);
|
||||
}
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn list_dir_root() {
|
||||
let dirs = os::list_dir(&Path("C:\\"));
|
||||
assert!(dirs.len() > 1);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn path_is_dir() {
|
||||
assert!((os::path_is_dir(&Path("."))));
|
||||
|
Loading…
Reference in New Issue
Block a user