Нема описа
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #[test]
  39. fn empty_with_newline_returns_correct_command() {
  40. assert_eq!(parse("\n12341234\n"), Err(ParseError(ErrorType::EmptyString)))
  41. }
  42. #[test]
  43. fn not_known_command_with_newline_returns_correct_command() {
  44. assert_eq!(parse("Hello\n123\n"), Err(ParseError(ErrorType::UnknownCommand)))
  45. }
  46. #[test]
  47. fn stage_with_newline_returns_correct_command() {
  48. assert_eq!(parse("STAGE 123\n456"), Ok(Command::Stage("123".to_string())))
  49. }
  50. #[test]
  51. fn control_with_newline_returns_correct_command() {
  52. assert_eq!(parse("CONTROL 123\n456"), Ok(Command::Control("123".to_string())))
  53. }
  54. #[test]
  55. fn retrieve_with_newline_returns_correct_command() {
  56. assert_eq!(parse("RETRIEVE 123\n456"), Ok(Command::Retrieve))
  57. }
  58. }