Merge branch 'martin-dev' into 'master'

Add test to parse_orientation() and parse_instruction()

See merge request mhart/DancingDroids!10
This commit is contained in:
Martin HART 2020-10-13 12:31:26 +02:00
commit 07fd3cb238
1 changed files with 29 additions and 0 deletions

View File

@ -41,3 +41,32 @@ fn open_file(filename: &str) -> io::Result<String> {
fn main() { fn main() {
let conf = open_file("two_robots.txt"); 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());
}
#[test]
fn test_open_file() {
assert!(open_file("two_robots.txt").is_ok());
assert!(open_file("test_unexisting_file.extension").is_err());
}
}