From 628d90fe44f1502bdac3f6cda6f99f44077b52ee Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Sun, 25 Jan 2015 13:47:07 +0000 Subject: [PATCH] Test extension extraction --- src/file.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/file.rs b/src/file.rs index b23af6d..a7b58d2 100644 --- a/src/file.rs +++ b/src/file.rs @@ -378,7 +378,6 @@ fn ext<'a>(name: &'a str) -> Option { name.rfind('.').map(|p| name[p+1..].to_string()) } - #[cfg(test)] mod test { pub use super::*; @@ -390,6 +389,21 @@ mod test { pub use ansi_term::Style::Plain; pub use ansi_term::Colour::Yellow; + #[test] + fn extension() { + assert_eq!(Some("dat".to_string()), super::ext("fester.dat")) + } + + #[test] + fn dotfile() { + assert_eq!(Some("vimrc".to_string()), super::ext(".vimrc")) + } + + #[test] + fn no_extension() { + assert_eq!(None, super::ext("jarlsberg")) + } + pub fn dummy_stat() -> io::FileStat { io::FileStat { size: 0,