Add test to
parse_orientation() parse_instruction()
This commit is contained in:
parent
e3c846eee5
commit
1ee584801a
22
src/main.rs
22
src/main.rs
@ -41,3 +41,25 @@ 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user