#[cfg(test)]
mod tests {
use crate::filetype::parse_block;
use crate::verifier::{VerificationResult, Verifier};
#[test]
fn slice_row_block() {
let input =
"> > > > > |\n4 1 -2 1 -3\n2 2 1 2 2\n3 1 -1 3 -1\n";
let block = parse_block(&input.lines().collect::<Vec<_>>()).unwrap();
assert_eq!(block.rows[0], vec![4.0, 1.0, -2.0, 1.0, -3.0]);
}
fn verify(path: &str) -> Vec<VerificationResult> {
Verifier::new().verify_file(&crate::parser::parse_file(std::path::Path::new(path)).unwrap())
}
fn cnt(r: &[VerificationResult]) -> (usize, usize, usize) {
let (mut c, mut i, mut e) = (0, 0, 0);
for x in r {
match x {
VerificationResult::Correct { .. } => c += 1,
VerificationResult::Incorrect { .. } => i += 1,
_ => e += 1,
}
}
(c, i, e)
}
#[test]
fn t_basic() {
assert_eq!(cnt(&verify("examples/row_ops/basic.lore")), (1, 0, 0));
}
#[test]
fn t_error() {
assert_eq!(
cnt(&verify("examples/row_ops/deliberate_error.lore")),
(0, 1, 0)
);
}
#[test]
fn t_fraction() {
assert_eq!(
cnt(&verify("examples/row_ops/fraction_scale.lore")),
(1, 0, 0)
);
}
#[test]
fn t_params() {
}
#[test]
fn t_full() {
assert_eq!(
cnt(&verify("examples/row_ops/full_sequence.lore")),
(5, 0, 0)
);
}
#[test]
fn t_diagonal() {
assert_eq!(
cnt(&verify("examples/row_ops/diagonal_scale.lore")),
(1, 0, 0)
);
}
#[test]
fn t_swap() {
assert_eq!(cnt(&verify("examples/row_ops/row_swap.lore")), (1, 0, 0));
}
#[test]
fn t_two_step() {
assert_eq!(cnt(&verify("examples/row_ops/two_step.lore")), (1, 0, 0));
}
#[test]
fn t_1x1() {
assert_eq!(cnt(&verify("examples/row_ops/single_1x1.lore")), (1, 0, 0));
}
#[test]
fn t_col_chain() {
assert_eq!(cnt(&verify("examples/col_ops/chain_basic.lore")), (1, 0, 0));
}
#[test]
fn t_col_multi() {
assert_eq!(cnt(&verify("examples/col_ops/multi_op.lore")), (1, 0, 0));
}
#[test]
fn t_col_error() {
assert_eq!(cnt(&verify("examples/col_ops/error.lore")), (0, 1, 0));
}
}