54 lines
1.5 KiB
Rust
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));
|
|
}
|
|
}
|