No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

task1.rs 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #[cfg(test)]
  2. mod tests {
  3. extern crate task1;
  4. use self::task1::Command;
  5. use self::task1::ErrorType;
  6. use self::task1::parse;
  7. use self::task1::ParseError;
  8. #[test]
  9. fn empty_returns_correct_command() {
  10. assert_eq!(parse("\n"), Err(ParseError(ErrorType::EmptyString)))
  11. }
  12. #[test]
  13. fn not_known_command_returns_correct_command() {
  14. assert_eq!(parse("Hello\n"), Err(ParseError(ErrorType::UnknownCommand)))
  15. }
  16. #[test]
  17. fn stage_returns_correct_command() {
  18. assert_eq!(
  19. parse("STAGE Hello\n"),
  20. Ok(Command::Stage("Hello".to_string()))
  21. )
  22. }
  23. #[test]
  24. fn control_returns_correct_command() {
  25. assert_eq!(
  26. parse("CONTROL Hello\n"),
  27. Ok(Command::Control("Hello".to_string()))
  28. )
  29. }
  30. #[test]
  31. fn retrieve_returns_correct_command() {
  32. assert_eq!(parse("RETRIEVE\n"), Ok(Command::Retrieve))
  33. }
  34. #[test]
  35. fn retrieve_with_arguments_returns_correct_command() {
  36. assert_eq!(parse("RETRIEVE Hello\n"), Ok(Command::Retrieve))
  37. }
  38. }