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