Exhaustive tests for small dimensions
This commit is contained in:
parent
ed833506a9
commit
1dccdb1f20
@ -85,7 +85,7 @@ pub fn matrix(stream: TokenStream) -> TokenStream {
|
||||
// TODO: Use quote_spanned instead??
|
||||
// TODO: Construct directly from array?
|
||||
let output = quote! {
|
||||
nalgebra::MatrixMN::<_, nalgebra::dimension::#row_dim, nalgebra::dimension::#col_dim>
|
||||
nalgebra::MatrixMN::<_, nalgebra::#row_dim, nalgebra::dimension::#col_dim>
|
||||
::from_column_slice(&[#(#entries_col_major),*])
|
||||
};
|
||||
|
||||
|
@ -1,10 +1,35 @@
|
||||
use nalgebra_macros::matrix;
|
||||
use nalgebra::Matrix3x2;
|
||||
use nalgebra::{MatrixMN, Matrix3x2, U0, U1, Matrix1x2, Matrix1x3, Matrix1x4, Matrix2x1, Matrix2, Matrix2x3, Matrix2x4, Matrix3x1, Matrix3, Matrix3x4, Matrix4x1, Matrix4x2, Matrix4x3, Matrix4};
|
||||
|
||||
#[test]
|
||||
fn matrix_basic_construction() {
|
||||
let matrix: Matrix3x2<_> = matrix![ 1, 2;
|
||||
3, 4;
|
||||
5, 6 ];
|
||||
assert_eq!(matrix, Matrix3x2::new(1, 2, 3, 4, 5, 6));
|
||||
fn matrix_small_dims_exhaustive() {
|
||||
// 0x0
|
||||
assert_eq!(matrix![], MatrixMN::<i32, U0, U0>::zeros());
|
||||
|
||||
// 1xN
|
||||
assert_eq!(matrix![1], MatrixMN::<i32, U1, U1>::new(1));
|
||||
assert_eq!(matrix![1, 2], Matrix1x2::new(1, 2));
|
||||
assert_eq!(matrix![1, 2, 3], Matrix1x3::new(1, 2, 3));
|
||||
assert_eq!(matrix![1, 2, 3, 4], Matrix1x4::new(1, 2, 3, 4));
|
||||
|
||||
// 2xN
|
||||
assert_eq!(matrix![1; 2], Matrix2x1::new(1, 2));
|
||||
assert_eq!(matrix![1, 2; 3, 4], Matrix2::new(1, 2, 3, 4));
|
||||
assert_eq!(matrix![1, 2, 3; 4, 5, 6], Matrix2x3::new(1, 2, 3, 4, 5, 6));
|
||||
assert_eq!(matrix![1, 2, 3, 4; 5, 6, 7, 8], Matrix2x4::new(1, 2, 3, 4, 5, 6, 7, 8));
|
||||
|
||||
// 3xN
|
||||
assert_eq!(matrix![1; 2; 3], Matrix3x1::new(1, 2, 3));
|
||||
assert_eq!(matrix![1, 2; 3, 4; 5, 6], Matrix3x2::new(1, 2, 3, 4, 5, 6));
|
||||
assert_eq!(matrix![1, 2, 3; 4, 5, 6; 7, 8, 9], Matrix3::new(1, 2, 3, 4, 5, 6, 7, 8, 9));
|
||||
assert_eq!(matrix![1, 2, 3, 4; 5, 6, 7, 8; 9, 10, 11, 12],
|
||||
Matrix3x4::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
|
||||
|
||||
// 4xN
|
||||
assert_eq!(matrix![1; 2; 3; 4], Matrix4x1::new(1, 2, 3, 4));
|
||||
assert_eq!(matrix![1, 2; 3, 4; 5, 6; 7, 8], Matrix4x2::new(1, 2, 3, 4, 5, 6, 7, 8));
|
||||
assert_eq!(matrix![1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12],
|
||||
Matrix4x3::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
|
||||
assert_eq!(matrix![1, 2, 3, 4; 5, 6, 7, 8; 9, 10, 11, 12; 13, 14, 15, 16],
|
||||
Matrix4::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
|
||||
}
|
Loading…
Reference in New Issue
Block a user