Browse Source

Renamed Error Type and ran rustfmt

Lorenz Bung 7 years ago
parent
commit
09c7e5ad79
2 changed files with 10 additions and 7 deletions
  1. 5
    5
      hw9/task1/src/lib.rs
  2. 5
    2
      hw9/task1/tests/task1.rs

+ 5
- 5
hw9/task1/src/lib.rs View File

14
                     Command::Control(cmd.to_string())
14
                     Command::Control(cmd.to_string())
15
                 }
15
                 }
16
                 Some("RETRIEVE") => Command::Retrieve,
16
                 Some("RETRIEVE") => Command::Retrieve,
17
-                Some(_) => Command::Error(ParseError::UnknownCommand),
18
-                None => Command::Error(ParseError::EmptyString),
17
+                Some(_) => Command::ParseError(ErrorType::UnknownCommand),
18
+                None => Command::ParseError(ErrorType::EmptyString),
19
             }
19
             }
20
         }
20
         }
21
-        None => Command::Error(ParseError::EmptyString),
21
+        None => Command::ParseError(ErrorType::EmptyString),
22
     }
22
     }
23
 }
23
 }
24
 
24
 
27
     Stage(String),
27
     Stage(String),
28
     Control(String),
28
     Control(String),
29
     Retrieve,
29
     Retrieve,
30
-    Error(ParseError),
30
+    ParseError(ErrorType),
31
 }
31
 }
32
 
32
 
33
 #[derive(Debug, PartialEq)]
33
 #[derive(Debug, PartialEq)]
34
-pub enum ParseError {
34
+pub enum ErrorType {
35
     UnknownCommand,
35
     UnknownCommand,
36
     EmptyString,
36
     EmptyString,
37
 }
37
 }

+ 5
- 2
hw9/task1/tests/task1.rs View File

10
 
10
 
11
     #[test]
11
     #[test]
12
     fn empty_returns_correct_command() {
12
     fn empty_returns_correct_command() {
13
-        assert_eq!(parse("\n"), Command::Error(ParseError::EmptyString))
13
+        assert_eq!(parse("\n"), Command::ParseError(ErrorType::EmptyString))
14
     }
14
     }
15
 
15
 
16
     #[test]
16
     #[test]
17
     fn not_known_command_returns_correct_command() {
17
     fn not_known_command_returns_correct_command() {
18
-        assert_eq!(parse("Hello"), Command::Error(ParseError::UnknownCommand))
18
+        assert_eq!(
19
+            parse("Hello"),
20
+            Command::ParseError(ErrorType::UnknownCommand)
21
+        )
19
     }
22
     }
20
 
23
 
21
     #[test]
24
     #[test]

Loading…
Cancel
Save