Split some matrix tests into inline modules

This is primarily to reduce the scope of imports around the quickcheck
part of the tests. It also converts comments into more structured code.
This commit is contained in:
Eduard Bopp 2018-01-17 16:04:11 +01:00
parent 5b2e383320
commit 4a926736fe

View File

@ -8,8 +8,8 @@ use na::{self,
DVector, DMatrix,
Vector1, Vector2, Vector3, Vector4, Vector5, Vector6,
RowVector3, RowVector4, RowVector5,
Matrix1, Matrix2, Matrix3, Matrix4, Matrix5, Matrix6,
Matrix2x3, Matrix3x2, Matrix3x4, Matrix4x3, Matrix2x4, Matrix4x5, Matrix4x6,
Matrix2, Matrix3, Matrix4, Matrix5, Matrix6,
Matrix2x3, Matrix3x2, Matrix3x4, Matrix4x3, Matrix2x4, Matrix4x5,
MatrixMN};
use na::dimension::{U8, U15};
@ -672,12 +672,11 @@ fn set_row_column() {
}
#[cfg(feature = "arbitrary")]
quickcheck! {
/*
*
* Transposition.
*
*/
mod transposition_tests {
use super::*;
use na::Matrix4x6;
quickcheck! {
fn transpose_transpose_is_self(m: Matrix2x3<f64>) -> bool {
m.transpose().transpose() == m
}
@ -715,14 +714,15 @@ quickcheck! {
fn tr_mul_is_transpose_then_mul(m: Matrix4x6<f64>, v: Vector4<f64>) -> bool {
relative_eq!(m.transpose() * v, m.tr_mul(&v), epsilon = 1.0e-7)
}
}
}
/*
*
*
* Inversion.
*
*
*/
#[cfg(feature = "arbitrary")]
mod inversion_tests {
use super::*;
use na::Matrix1;
quickcheck! {
fn self_mul_inv_is_id_dim1(m: Matrix1<f64>) -> bool {
if let Some(im) = m.try_inverse() {
let id = Matrix1::one();
@ -777,12 +777,15 @@ quickcheck! {
true
}
}
}
}
/*
*
* Normalization.
*
*/
#[cfg(feature = "arbitrary")]
mod normalization_tests {
use super::*;
quickcheck! {
fn normalized_vec_norm_is_one(v: Vector3<f64>) -> bool {
if let Some(nv) = v.try_normalize(1.0e-10) {
relative_eq!(nv.norm(), 1.0, epsilon = 1.0e-7)
@ -800,6 +803,7 @@ quickcheck! {
true
}
}
}
}
// FIXME: move this to alga ?