#![doc = include_str!("../../docs/matrix/mod.md")]
pub mod cmp;
pub mod create;
pub mod io;
pub mod items;
pub mod iter;
pub mod ops;
pub mod update;
pub mod views;
#[derive(Debug, Clone)]
#[allow(clippy::module_name_repetitions)]
pub struct CSVBinaryMatrix {
number_of_rows: usize,
number_of_columns: usize,
distances: Vec<usize>,
is_reversed: bool,
}
impl CSVBinaryMatrix {
#[must_use]
pub fn number_of_rows(&self) -> usize {
self.number_of_rows
}
#[must_use]
pub fn number_of_columns(&self) -> usize {
self.number_of_columns
}
}
#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;
use rstest::{fixture, rstest};
use super::CSVBinaryMatrix;
#[fixture]
pub fn zeros_matrix() -> CSVBinaryMatrix {
CSVBinaryMatrix {
number_of_rows: 3,
number_of_columns: 3,
distances: vec![8],
is_reversed: false,
}
}
#[fixture]
pub fn zeros_matrix_bis() -> CSVBinaryMatrix {
CSVBinaryMatrix {
number_of_rows: 3,
number_of_columns: 3,
distances: vec![8],
is_reversed: true,
}
}
#[fixture]
pub fn ones_matrix() -> CSVBinaryMatrix {
CSVBinaryMatrix {
number_of_rows: 3,
number_of_columns: 3,
distances: vec![0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
is_reversed: false,
}
}
#[fixture]
pub fn matrix_a() -> CSVBinaryMatrix {
CSVBinaryMatrix {
number_of_rows: 3,
number_of_columns: 3,
distances: vec![0, 1, 1, 1, 4, 1],
is_reversed: false,
}
}
#[fixture]
pub fn matrix_a_bis() -> CSVBinaryMatrix {
CSVBinaryMatrix {
number_of_rows: 3,
number_of_columns: 3,
distances: vec![1, 4, 1, 1, 1, 0],
is_reversed: true,
}
}
#[rstest]
fn debug(zeros_matrix: CSVBinaryMatrix, matrix_a: CSVBinaryMatrix) {
assert_eq!(
format!("{zeros_matrix:?}"),
"CSVBinaryMatrix { number_of_rows: 3, number_of_columns: 3, distances: [8], is_reversed: false }"
);
assert_eq!(
format!("{matrix_a:?}"),
"CSVBinaryMatrix { number_of_rows: 3, number_of_columns: 3, distances: [0, 1, 1, 1, 4, 1], is_reversed: false }"
);
}
#[rstest]
fn number_of_rows(matrix_a: CSVBinaryMatrix) {
assert_eq!(matrix_a.number_of_rows(), 3);
}
#[rstest]
fn number_of_columns(matrix_a: CSVBinaryMatrix) {
assert_eq!(matrix_a.number_of_columns(), 3);
}
}