Add test to

parse_orientation()
parse_instruction()
This commit is contained in:
mhart 2020-10-13 12:07:47 +02:00
parent e3c846eee5
commit 1ee584801a
1 changed files with 22 additions and 0 deletions

View File

@ -41,3 +41,25 @@ fn open_file(filename: &str) -> io::Result<String> {
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());
}
}