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

54 lines
1.5 KiB
Rust
Raw Normal View History

2024-09-15 10:32:02 +00:00
#[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));
}
}