Test cols/rows
This commit is contained in:
parent
e63383570e
commit
7a68f5ad19
@ -502,8 +502,8 @@ impl<const X: usize, const Y: usize, const SIZE: usize> BinaryMap<X, Y, SIZE> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lines(&self) -> impl Iterator<Item = &[MazePart]> {
|
pub fn rows(&self) -> impl Iterator<Item = &[MazePart]> {
|
||||||
self.0.windows(X)
|
self.0.windows(X).step_by(X)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 0 1 2
|
/// 0 1 2
|
||||||
@ -539,7 +539,22 @@ mod column_iter_tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn check() {
|
fn rows() {
|
||||||
|
let grid = [
|
||||||
|
1, 2, 3, //
|
||||||
|
4, 5, 6, //
|
||||||
|
7, 8, 9, //
|
||||||
|
10, 11, 12, //
|
||||||
|
];
|
||||||
|
let mut it = grid.windows(3).step_by(3);
|
||||||
|
assert_eq!(it.next().map(Vec::from), Some(vec![1, 2, 3]));
|
||||||
|
assert_eq!(it.next().map(Vec::from), Some(vec![4, 5, 6]));
|
||||||
|
assert_eq!(it.next().map(Vec::from), Some(vec![7, 8, 9]));
|
||||||
|
assert_eq!(it.next().map(Vec::from), Some(vec![10, 11, 12]));
|
||||||
|
assert_eq!(it.next(), None);
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn cols() {
|
||||||
let grid = [
|
let grid = [
|
||||||
1, 2, 3, //
|
1, 2, 3, //
|
||||||
4, 5, 6, //
|
4, 5, 6, //
|
||||||
|
Loading…
Reference in New Issue
Block a user