diff --git a/examples/matrixcompare.rs b/examples/matrixcompare.rs index 60c632d3..713be25f 100644 --- a/examples/matrixcompare.rs +++ b/examples/matrixcompare.rs @@ -1,60 +1,63 @@ extern crate nalgebra as na; -#[macro_use] -extern crate quickcheck; - -use na::{U3, U4, MatrixMN}; +use matrixcompare::comparators::{AbsoluteElementwiseComparator, ExactElementwiseComparator}; use matrixcompare::compare_matrices; -use matrixcompare::comparators::{ExactElementwiseComparator, AbsoluteElementwiseComparator}; +use na::{MatrixMN, U3, U4}; fn compare_integers_fail() { println!("Comparing two integer matrices."); + #[rustfmt::skip] let a = MatrixMN::<_, U3, U4>::from_row_slice(&[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -2, 11 ]); + #[rustfmt::skip] let b = MatrixMN::<_, U3, U4>::from_row_slice(&[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]); - if let Some(msg) = compare_matrices(a, b, &ExactElementwiseComparator).panic_message() { - println!("{}", msg); + if let Err(err) = compare_matrices(a, b, &ExactElementwiseComparator) { + println!("{}", err); } } fn compare_different_size() { println!("Comparing matrices of different size."); + #[rustfmt::skip] let a = MatrixMN::<_, U3, U3>::from_row_slice(&[ 0, 1, 2, 4, 5, 6, 8, 9, 10, ]); + #[rustfmt::skip] let b = MatrixMN::<_, U3, U4>::from_row_slice(&[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]); - if let Some(msg) = compare_matrices(a, b, &ExactElementwiseComparator).panic_message() { - println!("{}", msg); + if let Err(err) = compare_matrices(a, b, &ExactElementwiseComparator) { + println!("{}", err); } } fn compare_f64_abs_tol_fail() { println!("Comparing two f64 matrices."); + #[rustfmt::skip] let a = MatrixMN::::from_row_slice(&[ 0.0, 1.0, 2.0 + 1e-10, 4.0, 5.0, 6.0, 8.0, 9.0, 10.0, ]); + #[rustfmt::skip] let b = MatrixMN::<_, U3, U3>::from_row_slice(&[ 0.0, 1.0, 2.0, 4.0, 5.0, 6.0, @@ -62,8 +65,8 @@ fn compare_f64_abs_tol_fail() { ]); let cmp = AbsoluteElementwiseComparator { tol: 1e-12 }; - if let Some(msg) = compare_matrices(a, b, &cmp).panic_message() { - println!("{}", msg); + if let Err(err) = compare_matrices(a, b, &cmp) { + println!("{}", err); } } @@ -76,4 +79,4 @@ fn main() { compare_f64_abs_tol_fail(); println!("======================================================"); compare_different_size(); -} \ No newline at end of file +} diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 8107a1dc..6e6aaba5 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -160,8 +160,9 @@ impl Abomonation for Matrix> - matrixcompare_core::Matrix for Matrix { +impl> matrixcompare_core::Matrix + for Matrix +{ fn rows(&self) -> usize { self.nrows() } @@ -176,8 +177,9 @@ impl> } #[cfg(feature = "compare")] -impl> - matrixcompare_core::DenseAccess for Matrix { +impl> matrixcompare_core::DenseAccess + for Matrix +{ fn fetch_single(&self, row: usize, col: usize) -> N { self.index((row, col)).clone() } diff --git a/tests/core/matrixcompare.rs b/tests/core/matrixcompare.rs index d4b6f142..df112173 100644 --- a/tests/core/matrixcompare.rs +++ b/tests/core/matrixcompare.rs @@ -4,7 +4,7 @@ //! The tests here only check that the necessary trait implementations are correctly implemented, //! in addition to some sanity checks with example input. -use nalgebra::{U4, U5, MatrixMN, DMatrix}; +use nalgebra::{DMatrix, MatrixMN, U4, U5}; use matrixcompare::{assert_matrix_eq, DenseAccess}; @@ -31,6 +31,7 @@ quickcheck! { #[test] fn assert_matrix_eq_dense_positive_comparison() { + #[rustfmt::skip] let a = MatrixMN::<_, U4, U5>::from_row_slice(&[ 1210, 1320, 1430, 1540, 1650, 2310, 2420, 2530, 2640, 2750, @@ -38,6 +39,7 @@ fn assert_matrix_eq_dense_positive_comparison() { 4510, 4620, 4730, 4840, 4950, ]); + #[rustfmt::skip] let b = MatrixMN::<_, U4, U5>::from_row_slice(&[ 1210, 1320, 1430, 1540, 1650, 2310, 2420, 2530, 2640, 2750, @@ -63,6 +65,7 @@ fn assert_matrix_eq_dense_positive_comparison() { #[test] #[should_panic] fn assert_matrix_eq_dense_negative_comparison() { + #[rustfmt::skip] let a = MatrixMN::<_, U4, U5>::from_row_slice(&[ 1210, 1320, 1430, 1540, 1650, 2310, 2420, 2530, 2640, 2750, @@ -70,6 +73,7 @@ fn assert_matrix_eq_dense_negative_comparison() { 4510, 4620, -4730, 4840, 4950, ]); + #[rustfmt::skip] let b = MatrixMN::<_, U4, U5>::from_row_slice(&[ 1210, 1320, 1430, 1540, 1650, 2310, 2420, 2530, 2640, 2750, @@ -78,4 +82,4 @@ fn assert_matrix_eq_dense_negative_comparison() { ]); assert_matrix_eq!(a, b); -} \ No newline at end of file +}