#[cfg(test)] mod tests { extern crate task1; use self::task1::Command; use self::task1::ErrorType; use self::task1::parse; use self::task1::ParseError; #[test] fn empty_returns_correct_command() { assert_eq!(parse("\n"), Err(ParseError(ErrorType::EmptyString))) } #[test] fn not_known_command_returns_correct_command() { assert_eq!( parse("Hello"), Err(ParseError(ErrorType::UnknownCommand)) ) } #[test] fn stage_returns_correct_command() { assert_eq!(parse("STAGE Hello"), Ok(Command::Stage("Hello".to_string()))) } #[test] fn control_returns_correct_command() { assert_eq!( parse("CONTROL Hello"), Ok(Command::Control("Hello".to_string())) ) } #[test] fn retrieve_returns_correct_command() { assert_eq!(parse("RETRIEVE"), Ok(Command::Retrieve)) } #[test] fn retrieve_with_arguments_returns_correct_command() { assert_eq!(parse("RETRIEVE Hello"), Ok(Command::Retrieve)) } }