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:
commit
07fd3cb238
29
src/main.rs
29
src/main.rs
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user