From 148b164aaa102924a526220599001ddd7fdd8086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Wed, 4 Aug 2021 17:56:57 +0200 Subject: [PATCH] Fix tests --- tests/core/edition.rs | 46 +++++++++++++++++++++++++++++++------------ tests/linalg/solve.rs | 2 +- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/tests/core/edition.rs b/tests/core/edition.rs index a8ee2536..bd882652 100644 --- a/tests/core/edition.rs +++ b/tests/core/edition.rs @@ -218,47 +218,67 @@ fn remove_columns() { 21, 22, 23, 24, 25, 31, 32, 33, 34, 35); - let expected1 = Matrix3x4::new( + let expected_a1 = Matrix3x4::new( 12, 13, 14, 15, 22, 23, 24, 25, 32, 33, 34, 35); - let expected2 = Matrix3x4::new( + let expected_a2 = Matrix3x4::new( 11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34); - let expected3 = Matrix3x4::new( + let expected_a3 = Matrix3x4::new( 11, 12, 14, 15, 21, 22, 24, 25, 31, 32, 34, 35); - assert_eq!(m.remove_column(0), expected1); - assert_eq!(m.remove_column(4), expected2); - assert_eq!(m.remove_column(2), expected3); + assert_eq!(m.remove_column(0), expected_a1); + assert_eq!(m.remove_column(4), expected_a2); + assert_eq!(m.remove_column(2), expected_a3); - let expected1 = Matrix3::new( + let expected_b1 = Matrix3::new( 13, 14, 15, 23, 24, 25, 33, 34, 35); - let expected2 = Matrix3::new( + let expected_b2 = Matrix3::new( 11, 12, 13, 21, 22, 23, 31, 32, 33); - let expected3 = Matrix3::new( + let expected_b3 = Matrix3::new( 11, 12, 15, 21, 22, 25, 31, 32, 35); - assert_eq!(m.remove_fixed_columns::<2>(0), expected1); - assert_eq!(m.remove_fixed_columns::<2>(3), expected2); - assert_eq!(m.remove_fixed_columns::<2>(2), expected3); + assert_eq!(m.remove_fixed_columns::<2>(0), expected_b1); + assert_eq!(m.remove_fixed_columns::<2>(3), expected_b2); + assert_eq!(m.remove_fixed_columns::<2>(2), expected_b3); // The following is just to verify that the return type dimensions is correctly inferred. let computed: Matrix<_, U3, Dynamic, _> = m.remove_columns(3, 2); - assert!(computed.eq(&expected2)); + assert!(computed.eq(&expected_b2)); + + /* + * Same thing but using a non-copy scalar type. + */ + let m = m.map(Box::new); + let expected_a1 = expected_a1.map(Box::new); + let expected_a2 = expected_a2.map(Box::new); + let expected_a3 = expected_a3.map(Box::new); + + assert_eq!(m.clone().remove_column(0), expected_a1); + assert_eq!(m.clone().remove_column(4), expected_a2); + assert_eq!(m.clone().remove_column(2), expected_a3); + + let expected_b1 = expected_b1.map(Box::new); + let expected_b2 = expected_b2.map(Box::new); + let expected_b3 = expected_b3.map(Box::new); + + assert_eq!(m.clone().remove_fixed_columns::<2>(0), expected_b1); + assert_eq!(m.clone().remove_fixed_columns::<2>(3), expected_b2); + assert_eq!(m.remove_fixed_columns::<2>(2), expected_b3); } #[test] diff --git a/tests/linalg/solve.rs b/tests/linalg/solve.rs index 1918af45..665865b9 100644 --- a/tests/linalg/solve.rs +++ b/tests/linalg/solve.rs @@ -11,7 +11,7 @@ macro_rules! gen_tests( fn unzero_diagonal(a: &mut Matrix4) { for i in 0..4 { - if a[(i, i)].norm1() < na::convert(1.0e-7) { + if a[(i, i)].clone().norm1() < na::convert(1.0e-7) { a[(i, i)] = T::one(); } }