From f6cbc82152a0ecc27f5aa49ccdc05e771e2fce76 Mon Sep 17 00:00:00 2001 From: sebcrozet Date: Thu, 13 Sep 2018 07:57:30 +0200 Subject: [PATCH] Add tests attempting to copy from a slice that is too small or too large. --- tests/core/matrix.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/core/matrix.rs b/tests/core/matrix.rs index 1b08acca..3c6f8e99 100644 --- a/tests/core/matrix.rs +++ b/tests/core/matrix.rs @@ -254,6 +254,22 @@ fn copy_from_slice() { assert_eq!(a, expected_a); } +#[should_panic] +#[test] +fn copy_from_slice_too_small() { + let mut a = Matrix3::zeros(); + let data = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; + a.copy_from_slice(&data); +} + +#[should_panic] +#[test] +fn copy_from_slice_too_large() { + let mut a = Matrix3::zeros(); + let data = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ]; + a.copy_from_slice(&data); +} + #[test] fn to_homogeneous() { let a = Vector3::new(1.0, 2.0, 3.0);