From 1ee584801a4b21d201aa0f7fd9b6a1ff54e9ab7c Mon Sep 17 00:00:00 2001 From: mhart Date: Tue, 13 Oct 2020 12:07:47 +0200 Subject: [PATCH] Add test to parse_orientation() parse_instruction() --- src/main.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main.rs b/src/main.rs index 6d12ddd..11282a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,3 +41,25 @@ fn open_file(filename: &str) -> io::Result { fn main() { let conf = open_file("two_robots.txt"); } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parse_orientation() { + assert!(parse_orientation('N').is_ok()); + assert!(parse_orientation('E').is_ok()); + assert!(parse_orientation('S').is_ok()); + assert!(parse_orientation('W').is_ok()); + assert!(parse_orientation('Z').is_err()); + } + + #[test] + fn test_parse_instruction() { + assert!(parse_instruction('L').is_ok()); + assert!(parse_instruction('R').is_ok()); + assert!(parse_instruction('F').is_ok()); + assert!(parse_instruction('Z').is_err()); + } +}