Nessuna descrizione
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.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #[test]
  8. fn empty_returns_correct_command() {
  9. assert_eq!(parse("\n"), Command::ParseError(ErrorType::EmptyString))
  10. }
  11. #[test]
  12. fn not_known_command_returns_correct_command() {
  13. assert_eq!(
  14. parse("Hello"),
  15. Command::ParseError(ErrorType::UnknownCommand)
  16. )
  17. }
  18. #[test]
  19. fn stage_returns_correct_command() {
  20. assert_eq!(parse("STAGE Hello"), Command::Stage("Hello".to_string()))
  21. }
  22. #[test]
  23. fn control_returns_correct_command() {
  24. assert_eq!(
  25. parse("CONTROL Hello"),
  26. Command::Control("Hello".to_string())
  27. )
  28. }
  29. #[test]
  30. fn retrieve_returns_correct_command() {
  31. assert_eq!(parse("RETRIEVE"), Command::Retrieve)
  32. }
  33. #[test]
  34. fn retrieve_with_arguments_returns_correct_command() {
  35. assert_eq!(parse("RETRIEVE Hello"), Command::Retrieve)
  36. }
  37. }