From 9a2f8e2d883aa582f30a593d297608bae87c6688 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 31 Dec 2020 10:13:06 +1000 Subject: [PATCH] fix clippy lints in tests --- examples/cargo/lib.rs | 3 +++ examples/ffi/rust_calling_c/src/matrix.rs | 20 ++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/examples/cargo/lib.rs b/examples/cargo/lib.rs index f1f13894c4..86bc3e30de 100644 --- a/examples/cargo/lib.rs +++ b/examples/cargo/lib.rs @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +// theoretically this should be safe, as unit tests are built without +// optimizations +#![allow(clippy::assertions_on_constants)] mod test { #[test] fn test_env_contents() { diff --git a/examples/ffi/rust_calling_c/src/matrix.rs b/examples/ffi/rust_calling_c/src/matrix.rs index 0c4c5fdff1..be51f81faf 100644 --- a/examples/ffi/rust_calling_c/src/matrix.rs +++ b/examples/ffi/rust_calling_c/src/matrix.rs @@ -117,34 +117,26 @@ mod test { #[test] fn test_size() { - let matrix = Matrix::new(2, 4, &vec![11, 12, 13, 14, - 21, 22, 23, 24]); + let matrix = Matrix::new(2, 4, &[11, 12, 13, 14, 21, 22, 23, 24]); assert_eq!(2, matrix.rows()); assert_eq!(4, matrix.cols()); } #[test] fn test_equal() { - let matrix_a = Matrix::new(2, 4, &vec![11, 12, 13, 14, - 21, 22, 23, 24]); - let matrix_b = Matrix::new(2, 4, &vec![11, 12, 13, 14, - 21, 22, 23, 24]); + let matrix_a = Matrix::new(2, 4, &[11, 12, 13, 14, 21, 22, 23, 24]); + let matrix_b = Matrix::new(2, 4, &[11, 12, 13, 14, 21, 22, 23, 24]); assert!(matrix_a.equal(&matrix_b)); - let matrix_c = Matrix::new(2, 4, &vec![12, 13, 14, 15, - 23, 24, 25, 26]); + let matrix_c = Matrix::new(2, 4, &[12, 13, 14, 15, 23, 24, 25, 26]); assert!(!matrix_a.equal(&matrix_c)); } #[test] fn test_transpose() { - let mut matrix = Matrix::new(2, 4, &vec![11, 12, 13, 14, - 21, 22, 23, 24]); + let mut matrix = Matrix::new(2, 4, &[11, 12, 13, 14, 21, 22, 23, 24]); matrix.transpose(); - let expected = Matrix::new(4, 2, &vec![11, 21, - 12, 22, - 13, 23, - 14, 24]); + let expected = Matrix::new(4, 2, &[11, 21, 12, 22, 13, 23, 14, 24]); assert!(matrix.equal(&expected)); } }