100-days-of-rust/Week-08/Day-52_Switch-On-The-Gravity/day52/tests/examples.rs

54 lines
1.5 KiB
Rust

#[cfg(test)]
mod examples {
use day52::switch_gravity_on;
#[test]
fn example1() {
let matrix = vec![
vec!['-', '#', '#', '-'],
vec!['-', '-', '-', '-'],
vec!['-', '-', '-', '-'],
vec!['-', '-', '-', '-'],
];
let expected = vec![
vec!['-', '-', '-', '-'],
vec!['-', '-', '-', '-'],
vec!['-', '-', '-', '-'],
vec!['-', '#', '#', '-'],
];
assert_eq!(switch_gravity_on(&matrix), Some(expected));
}
#[test]
fn example2() {
let matrix = vec![
vec!['-', '#', '#', '-'],
vec!['-', '-', '#', '-'],
vec!['-', '-', '-', '-'],
];
let expected = vec![
vec!['-', '-', '-', '-'],
vec!['-', '-', '#', '-'],
vec!['-', '#', '#', '-'],
];
assert_eq!(switch_gravity_on(&matrix), Some(expected));
}
#[test]
fn example3() {
let matrix = vec![
vec!['-', '#', '#', '#', '#', '-'],
vec!['#', '-', '-', '#', '#', '-'],
vec!['-', '#', '-', '-', '-', '-'],
vec!['-', '-', '-', '-', '-', '-'],
];
let expected = vec![
vec!['-', '-', '-', '-', '-', '-'],
vec!['-', '-', '-', '-', '-', '-'],
vec!['-', '#', '-', '#', '#', '-'],
vec!['#', '#', '#', '#', '#', '-'],
];
assert_eq!(switch_gravity_on(&matrix), Some(expected));
}
}