forked from M-Labs/nalgebra
Restructure test modules to avoid warnings
These warnings occurred only when running the test suite with no features. Lots of uses had to be rescoped into newly created modules to make it easier to separate these issues.
This commit is contained in:
parent
4a926736fe
commit
bba1993e58
@ -1,9 +1,8 @@
|
||||
use std::cmp;
|
||||
#![cfg(feature = "arbitrary")]
|
||||
|
||||
use std::cmp;
|
||||
use na::{DVector, DMatrix};
|
||||
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
/*
|
||||
*
|
||||
|
@ -1,8 +1,5 @@
|
||||
use num::{Zero, One};
|
||||
use num::Float;
|
||||
use std::fmt::Display;
|
||||
|
||||
use alga::linear::FiniteDimInnerSpace;
|
||||
|
||||
use na::{self,
|
||||
DVector, DMatrix,
|
||||
@ -806,10 +803,15 @@ mod normalization_tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
// FIXME: move this to alga ?
|
||||
macro_rules! finite_dim_inner_space_test(
|
||||
mod finite_dim_inner_space_tests {
|
||||
use super::*;
|
||||
use std::fmt::Display;
|
||||
use alga::linear::FiniteDimInnerSpace;
|
||||
|
||||
macro_rules! finite_dim_inner_space_test(
|
||||
($($Vector: ident, $orthonormal_subspace: ident, $orthonormalization: ident);* $(;)*) => {$(
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck!{
|
||||
fn $orthonormal_subspace(vs: Vec<$Vector<f64>>) -> bool {
|
||||
let mut given_basis = vs.clone();
|
||||
@ -861,23 +863,24 @@ macro_rules! finite_dim_inner_space_test(
|
||||
}
|
||||
}
|
||||
)*}
|
||||
);
|
||||
);
|
||||
|
||||
finite_dim_inner_space_test!(
|
||||
finite_dim_inner_space_test!(
|
||||
Vector1, orthonormal_subspace_basis1, orthonormalize1;
|
||||
Vector2, orthonormal_subspace_basis2, orthonormalize2;
|
||||
Vector3, orthonormal_subspace_basis3, orthonormalize3;
|
||||
Vector4, orthonormal_subspace_basis4, orthonormalize4;
|
||||
Vector5, orthonormal_subspace_basis5, orthonormalize5;
|
||||
Vector6, orthonormal_subspace_basis6, orthonormalize6;
|
||||
);
|
||||
);
|
||||
|
||||
/*
|
||||
/*
|
||||
*
|
||||
* Helper functions.
|
||||
*
|
||||
*/
|
||||
fn is_subspace_basis<T: FiniteDimInnerSpace<Real = f64> + Display>(vs: &[T]) -> bool {
|
||||
#[cfg(feature = "arbitrary")]
|
||||
fn is_subspace_basis<T: FiniteDimInnerSpace<Real = f64> + Display>(vs: &[T]) -> bool {
|
||||
for i in 0 .. vs.len() {
|
||||
// Basis elements must be normalized.
|
||||
if !relative_eq!(vs[i].norm(), 1.0, epsilon = 1.0e-7) {
|
||||
@ -895,4 +898,5 @@ fn is_subspace_basis<T: FiniteDimInnerSpace<Real = f64> + Display>(vs: &[T]) ->
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use na::{Point3, Perspective3, Orthographic3};
|
||||
use na::{Perspective3, Orthographic3};
|
||||
|
||||
#[test]
|
||||
fn perspective_inverse() {
|
||||
@ -22,7 +22,10 @@ fn orthographic_inverse() {
|
||||
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck!{
|
||||
mod quickcheck_tests {
|
||||
use na::{Point3, Perspective3, Orthographic3};
|
||||
|
||||
quickcheck!{
|
||||
fn perspective_project_unproject(pt: Point3<f64>) -> bool {
|
||||
let proj = Perspective3::new(800.0 / 600.0, 3.14 / 2.0, 1.0, 1000.0);
|
||||
|
||||
@ -40,4 +43,5 @@ quickcheck!{
|
||||
|
||||
relative_eq!(pt, unprojected, epsilon = 1.0e-7)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
use std::f64;
|
||||
use alga::general::Real;
|
||||
use na::{self, Vector2, Vector3, Rotation2, Rotation3, Unit};
|
||||
use na::{Vector2, Vector3};
|
||||
|
||||
#[test]
|
||||
fn angle_2() {
|
||||
@ -19,7 +17,12 @@ fn angle_3() {
|
||||
}
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck!(
|
||||
mod quickcheck_tests {
|
||||
use std::f64;
|
||||
use alga::general::Real;
|
||||
use na::{self, Vector2, Vector3, Rotation2, Rotation3, Unit};
|
||||
|
||||
quickcheck! {
|
||||
/*
|
||||
*
|
||||
* Euler angles.
|
||||
@ -202,4 +205,5 @@ quickcheck!(
|
||||
r == Rotation3::identity()
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
#![cfg(feature = "arbitrary")]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use alga::linear::{Transformation, ProjectiveTransformation};
|
||||
use na::{Vector3, Point3, Similarity3, Translation3, Isometry3, UnitQuaternion};
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck!(
|
||||
fn inverse_is_identity(i: Similarity3<f64>, p: Point3<f64>, v: Vector3<f64>) -> bool {
|
||||
let ii = i.inverse();
|
||||
|
@ -1,9 +1,8 @@
|
||||
#![cfg(feature = "arbitrary")]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use na::{Unit, UnitComplex, Vector2, Point2, Rotation2};
|
||||
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck!(
|
||||
|
||||
/*
|
||||
|
@ -1,9 +1,10 @@
|
||||
#![cfg(feature = "arbitrary")]
|
||||
|
||||
use std::cmp;
|
||||
|
||||
use na::{DMatrix, Matrix4};
|
||||
use na::balancing;
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
fn balancing_parlett_reinsch(n: usize) -> bool {
|
||||
let n = cmp::min(n, 10);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![cfg(feature = "arbitrary")]
|
||||
|
||||
use na::{DMatrix, Matrix2, Matrix4, Matrix5x3, Matrix3x5};
|
||||
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
fn bidiagonal(m: DMatrix<f64>) -> bool {
|
||||
if m.len() == 0 {
|
||||
|
@ -1,9 +1,11 @@
|
||||
use std::cmp;
|
||||
|
||||
use na::{DMatrix, Matrix2, Matrix3, Matrix4};
|
||||
use na::DMatrix;
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
mod quickcheck_tests {
|
||||
use std::cmp;
|
||||
use na::{DMatrix, Matrix2, Matrix3, Matrix4};
|
||||
|
||||
quickcheck! {
|
||||
fn symmetric_eigen(n: usize) -> bool {
|
||||
let n = cmp::max(1, cmp::min(n, 10));
|
||||
let m = DMatrix::<f64>::new_random(n, n);
|
||||
@ -54,6 +56,7 @@ quickcheck! {
|
||||
|
||||
relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-5)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test proposed on the issue #176 of rulinalg.
|
||||
|
@ -1,7 +1,4 @@
|
||||
use std::cmp;
|
||||
use na::{DMatrix, Matrix3, Matrix4, Matrix4x3, Matrix5x3, Matrix3x5,
|
||||
DVector, Vector4};
|
||||
|
||||
use na::Matrix3;
|
||||
|
||||
#[test]
|
||||
fn full_piv_lu_simple() {
|
||||
@ -42,7 +39,11 @@ fn full_piv_lu_simple_with_pivot() {
|
||||
}
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
mod quickcheck_tests {
|
||||
use std::cmp;
|
||||
use na::{DMatrix, Matrix4, Matrix4x3, Matrix5x3, Matrix3x5, DVector, Vector4};
|
||||
|
||||
quickcheck! {
|
||||
fn full_piv_lu(m: DMatrix<f64>) -> bool {
|
||||
let mut m = m;
|
||||
if m.len() == 0 {
|
||||
@ -152,4 +153,5 @@ quickcheck! {
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#![cfg(feature = "arbitrary")]
|
||||
|
||||
use std::cmp;
|
||||
use na::{DMatrix, Matrix2, Matrix4};
|
||||
|
||||
|
||||
#[test]
|
||||
fn hessenberg_simple() {
|
||||
let m = Matrix2::new(1.0, 0.0,
|
||||
@ -11,8 +12,6 @@ fn hessenberg_simple() {
|
||||
assert!(relative_eq!(m, p * h * p.transpose(), epsilon = 1.0e-7))
|
||||
}
|
||||
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
fn hessenberg(n: usize) -> bool {
|
||||
let n = cmp::max(1, cmp::min(n, 50));
|
||||
|
@ -1,7 +1,4 @@
|
||||
use std::cmp;
|
||||
use na::{DMatrix, Matrix3, Matrix4, Matrix4x3, Matrix5x3, Matrix3x5,
|
||||
DVector, Vector4};
|
||||
|
||||
use na::Matrix3;
|
||||
|
||||
#[test]
|
||||
fn lu_simple() {
|
||||
@ -40,7 +37,11 @@ fn lu_simple_with_pivot() {
|
||||
}
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
mod quickcheck_tests {
|
||||
use std::cmp;
|
||||
use na::{DMatrix, Matrix4, Matrix4x3, Matrix5x3, Matrix3x5, DVector, Vector4};
|
||||
|
||||
quickcheck! {
|
||||
fn lu(m: DMatrix<f64>) -> bool {
|
||||
let mut m = m;
|
||||
if m.len() == 0 {
|
||||
@ -146,4 +147,5 @@ quickcheck! {
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
#![cfg(feature = "arbitrary")]
|
||||
|
||||
use std::cmp;
|
||||
use na::{DMatrix, Matrix4, Matrix4x3, Matrix5x3, Matrix3x5,
|
||||
DVector, Vector4};
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
fn qr(m: DMatrix<f64>) -> bool {
|
||||
let qr = m.clone().qr();
|
||||
|
@ -1,5 +1,4 @@
|
||||
use std::cmp;
|
||||
use na::{DMatrix, Matrix2, Matrix3, Matrix4};
|
||||
use na::{DMatrix, Matrix3, Matrix4};
|
||||
|
||||
|
||||
#[test]
|
||||
@ -15,7 +14,11 @@ fn schur_simpl_mat3() {
|
||||
}
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
mod quickcheck_tests {
|
||||
use std::cmp;
|
||||
use na::{DMatrix, Matrix2, Matrix3, Matrix4};
|
||||
|
||||
quickcheck! {
|
||||
fn schur(n: usize) -> bool {
|
||||
let n = cmp::max(1, cmp::min(n, 10));
|
||||
let m = DMatrix::<f64>::new_random(n, n);
|
||||
@ -59,6 +62,7 @@ quickcheck! {
|
||||
}
|
||||
ok
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![cfg(feature = "arbitrary")]
|
||||
|
||||
use na::{Matrix4, Matrix4x5};
|
||||
|
||||
fn unzero_diagonal(a: &mut Matrix4<f64>) {
|
||||
@ -8,7 +10,6 @@ fn unzero_diagonal(a: &mut Matrix4<f64>) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
fn solve_lower_triangular(a: Matrix4<f64>, b: Matrix4x5<f64>) -> bool {
|
||||
let mut a = a;
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::cmp;
|
||||
|
||||
use na::{DMatrix, Matrix2, Matrix3, Matrix4, Matrix6, Matrix5x2, Matrix5x3, Matrix2x5, Matrix3x5,
|
||||
DVector};
|
||||
|
||||
use na::{DMatrix, Matrix6};
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
mod quickcheck_tests {
|
||||
use std::cmp;
|
||||
use na::{DMatrix, Matrix2, Matrix3, Matrix4, Matrix5x2, Matrix5x3, Matrix2x5, Matrix3x5, DVector};
|
||||
|
||||
quickcheck! {
|
||||
fn svd(m: DMatrix<f64>) -> bool {
|
||||
if m.len() > 0 {
|
||||
let svd = m.clone().svd(true, true);
|
||||
@ -137,6 +137,7 @@ quickcheck! {
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test proposed on the issue #176 of rulinalg.
|
||||
|
@ -1,9 +1,9 @@
|
||||
#![cfg(feature = "arbitrary")]
|
||||
|
||||
use std::cmp;
|
||||
|
||||
use na::{DMatrix, Matrix2, Matrix4};
|
||||
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
quickcheck! {
|
||||
fn symm_tridiagonal(n: usize) -> bool {
|
||||
let n = cmp::max(1, cmp::min(n, 50));
|
||||
|
Loading…
Reference in New Issue
Block a user