Test: Get Box

This commit is contained in:
Jonas Zeunert
2024-02-20 12:52:21 +01:00
parent 2d1c285e81
commit c189d4ac3b

View File

@@ -54,8 +54,16 @@ impl Playfield {
}
}
}
pub fn get_column(&self, index: usize) -> Vec<Field> {
self.fields.iter().map(|row| row[index].clone()).collect()
pub fn get_column(&self, col_index: usize) -> Vec<Field> {
self.fields
.iter()
.map(|row| row[col_index].clone())
.collect()
}
pub fn get_box(&self, row: usize, col: usize) -> Vec<&Field> {
let result: Vec<&Field> = Vec::new();
result
}
pub fn convert_index(&self, index: usize) -> (usize, usize) {
let row = index / self.size;
@@ -127,6 +135,14 @@ mod tests {
assert_eq!(column_3, expected_3);
}
}
mod get_box {
use super::*;
#[test]
fn simple() {
let playfield = Playfield::new(&"1 2 3 4 4 3 2 1 3 2 1 4 2 1 4 3".to_string(), 4);
let expected = vec![Field::new(1), Field::new(2), Field::new(4), Field::new(5)];
}
}
mod calculate_box_size {
use super::*;
#[test]