100-days-of-rust/Week-05/Day-29_Traffic-Light-Checker/day29/tests/examples.rs

43 lines
891 B
Rust
Raw Normal View History

#[cfg(test)]
mod examples {
use day29::{tl_checker, TLR};
#[test]
fn example1() {
assert_eq!(
tl_checker(&['R', 'G', 'Y', 'R', 'C', 'R', 'G', 'Y', 'R']),
TLR::Accept
);
}
#[test]
fn example2() {
assert_eq!(tl_checker(&['G', 'Y', 'R', 'G', 'Y', 'R']), TLR::Reject);
}
#[test]
fn example3() {
assert_eq!(tl_checker(&['R', 'Y', 'G', 'P']), TLR::Reject);
}
#[test]
fn example4() {
assert_eq!(tl_checker(&['R', 'G', 'Y']), TLR::Error);
}
#[test]
fn example5() {
assert_eq!(tl_checker(&['X', '8', 'S']), TLR::Error);
}
#[test]
fn example6() {
assert_eq!(
tl_checker(&[
'R', 'G', 'Y', 'R', 'C', 'R', 'P', 'R', 'G', 'Y', 'R', 'G', 'Y', 'R', 'G', 'Y', 'R'
]),
TLR::Error
);
}
}