Mint vector tests
This commit is contained in:
parent
7d96007bdb
commit
2cd79851c3
|
@ -153,7 +153,7 @@ macro_rules! array_vector_conversion(
|
||||||
fn $array_vector_conversion_i() {
|
fn $array_vector_conversion_i() {
|
||||||
let v = $Vector::from_fn(|i, _| i);
|
let v = $Vector::from_fn(|i, _| i);
|
||||||
let arr: [usize; $SZ] = v.into();
|
let arr: [usize; $SZ] = v.into();
|
||||||
let arr_ref = v.as_ref();
|
let arr_ref: &[usize; $SZ] = v.as_ref();
|
||||||
let v2 = $Vector::from(arr);
|
let v2 = $Vector::from(arr);
|
||||||
|
|
||||||
for i in 0 .. $SZ {
|
for i in 0 .. $SZ {
|
||||||
|
@ -255,3 +255,31 @@ array_matrix_conversion!(
|
||||||
array_matrix_conversion_6_5, Matrix6x5, (6, 5);
|
array_matrix_conversion_6_5, Matrix6x5, (6, 5);
|
||||||
array_matrix_conversion_6_6, Matrix6, (6, 6);
|
array_matrix_conversion_6_6, Matrix6, (6, 6);
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
macro_rules! mint_vector_conversion(
|
||||||
|
($($mint_vector_conversion_i: ident, $Vector: ident, $SZ: expr);* $(;)*) => {$(
|
||||||
|
#[test]
|
||||||
|
fn $mint_vector_conversion_i() {
|
||||||
|
let v = $Vector::from_fn(|i, _| i);
|
||||||
|
let mv: mint::$Vector<usize> = v.into();
|
||||||
|
let mv_ref: &mint::$Vector<usize> = v.as_ref();
|
||||||
|
let v2 = $Vector::from(mv);
|
||||||
|
|
||||||
|
let arr: [usize; $SZ] = mv.into();
|
||||||
|
for i in 0 .. $SZ {
|
||||||
|
assert_eq!(arr[i], i);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_eq!(&mv, mv_ref);
|
||||||
|
assert_eq!(v, v2);
|
||||||
|
}
|
||||||
|
)*}
|
||||||
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
mint_vector_conversion!(
|
||||||
|
mint_vector_conversion_2, Vector2, 2;
|
||||||
|
mint_vector_conversion_3, Vector3, 3;
|
||||||
|
mint_vector_conversion_4, Vector4, 4;
|
||||||
|
);
|
||||||
|
|
|
@ -6,3 +6,5 @@ mod blas;
|
||||||
mod serde;
|
mod serde;
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
mod abomonation;
|
mod abomonation;
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
extern crate mint;
|
||||||
|
|
|
@ -7,6 +7,8 @@ extern crate num_traits as num;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
extern crate abomonation;
|
extern crate abomonation;
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
extern crate mint;
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
extern crate alga;
|
extern crate alga;
|
||||||
extern crate nalgebra as na;
|
extern crate nalgebra as na;
|
||||||
|
|
Loading…
Reference in New Issue