Add tests attempting to copy from a slice that is too small or too large.

This commit is contained in:
sebcrozet 2018-09-13 07:57:30 +02:00 committed by Sébastien Crozet
parent 99b54465c7
commit f6cbc82152
1 changed files with 16 additions and 0 deletions

View File

@ -254,6 +254,22 @@ fn copy_from_slice() {
assert_eq!(a, expected_a); 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] #[test]
fn to_homogeneous() { fn to_homogeneous() {
let a = Vector3::new(1.0, 2.0, 3.0); let a = Vector3::new(1.0, 2.0, 3.0);