Moved test from main.rs to types.rs

This commit is contained in:
Danilo Bargen 2016-04-03 00:48:30 +02:00
commit 30af8ca90f
2 changed files with 13 additions and 18 deletions

View file

@ -262,21 +262,3 @@ fn main() {
process::exit(1);
}
}
#[cfg(test)]
mod test {
use types::LineType;
#[test]
fn test_linetype_from_str() {
assert_eq!(LineType::from(""), LineType::Empty);
assert_eq!(LineType::from(" \n \r"), LineType::Empty);
assert_eq!(LineType::from("# Hello there"), LineType::Title("Hello there".into()));
assert_eq!(LineType::from("> tis a description \n"), LineType::Description("tis a description".into()));
assert_eq!(LineType::from("- some command"), LineType::ExampleText("some command".into()));
assert_eq!(LineType::from("`$ cargo run`"), LineType::ExampleCode("$ cargo run".into()));
assert_eq!(LineType::from("`$ cargo run"), LineType::Other("`$ cargo run".into()));
assert_eq!(LineType::from("jkl\u{f6}"), LineType::Other("jkl\u{f6}".into()));
}
}

View file

@ -65,6 +65,7 @@ mod test {
extern crate docopt;
use super::OsType::{self, Linux, OsX, SunOs, Other};
use super::LineType;
use rustc_serialize::json;
#[test]
@ -85,4 +86,16 @@ mod test {
fn test_os_type_decoding_unknown() {
assert!(json::decode::<OsType>("\"lindows\"").is_err());
}
#[test]
fn test_linetype_from_str() {
assert_eq!(LineType::from(""), LineType::Empty);
assert_eq!(LineType::from(" \n \r"), LineType::Empty);
assert_eq!(LineType::from("# Hello there"), LineType::Title("Hello there".into()));
assert_eq!(LineType::from("> tis a description \n"), LineType::Description("tis a description".into()));
assert_eq!(LineType::from("- some command"), LineType::ExampleText("some command".into()));
assert_eq!(LineType::from("`$ cargo run`"), LineType::ExampleCode("$ cargo run".into()));
assert_eq!(LineType::from("`$ cargo run"), LineType::Other("`$ cargo run".into()));
assert_eq!(LineType::from("jkl\u{f6}"), LineType::Other("jkl\u{f6}".into()));
}
}