Açıklama Yok
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.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 stage_with_newline_returns_correct_command() {
  40. assert_eq!(parse("STAGE 123\n456"), Ok(Command::Stage("123".to_string())))
  41. }
  42. #[test]
  43. fn control_with_newline_returns_correct_command() {
  44. assert_eq!(parse("Control 123\n456"), Ok(Command::Control("123".to_string())))
  45. }
  46. #[test]
  47. fn retrieve_with_newline_returns_correct_command() {
  48. assert_eq!(parse("RETRIEVE 123\n456"), Ok(Command::Retrieve))
  49. }
  50. }