diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-10-28 23:23:51 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-10-28 23:34:01 -0700 |
| commit | 802deac3233d91bcd6ba5a87c6a4de8b3e12425e (patch) | |
| tree | 29843187afb551550e9804df7408a0028ee97b03 /src/test/stdtest | |
| parent | a2377ccf91158ce5c9da2e5d0cc1f56fa562b2fe (diff) | |
| download | rust-802deac3233d91bcd6ba5a87c6a4de8b3e12425e.tar.gz rust-802deac3233d91bcd6ba5a87c6a4de8b3e12425e.zip | |
stdlib: Add fs::splitext
Splits a path into the filename + extension
Diffstat (limited to 'src/test/stdtest')
| -rw-r--r-- | src/test/stdtest/fs.rs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/test/stdtest/fs.rs b/src/test/stdtest/fs.rs index 14467ea59a6..66cec07c795 100644 --- a/src/test/stdtest/fs.rs +++ b/src/test/stdtest/fs.rs @@ -156,4 +156,60 @@ fn normalize12() { #[cfg(target_os = "win32")] fn path_is_absolute_win32() { assert fs::path_is_absolute("C:/whatever"); +} + +#[test] +fn splitext_empty() { + let (base, ext) = fs::splitext(""); + assert base == ""; + assert ext == ""; +} + +#[test] +fn splitext_ext() { + let (base, ext) = fs::splitext("grum.exe"); + assert base == "grum"; + assert ext == ".exe"; +} + +#[test] +fn splitext_noext() { + let (base, ext) = fs::splitext("grum"); + assert base == "grum"; + assert ext == ""; +} + +#[test] +fn splitext_dotfile() { + let (base, ext) = fs::splitext(".grum"); + assert base == ".grum"; + assert ext == ""; +} + +#[test] +fn splitext_path_ext() { + let (base, ext) = fs::splitext("oh/grum.exe"); + assert base == "oh/grum"; + assert ext == ".exe"; +} + +#[test] +fn splitext_path_noext() { + let (base, ext) = fs::splitext("oh/grum"); + assert base == "oh/grum"; + assert ext == ""; +} + +#[test] +fn splitext_dot_in_path() { + let (base, ext) = fs::splitext("oh.my/grum"); + assert base == "oh.my/grum"; + assert ext == ""; +} + +#[test] +fn splitext_nobasename() { + let (base, ext) = fs::splitext("oh.my/"); + assert base == "oh.my/"; + assert ext == ""; } \ No newline at end of file |
