Fix tests
This commit is contained in:
parent
4cefbf763c
commit
1c51fba5a6
3 changed files with 28 additions and 27 deletions
|
@ -1,5 +1,6 @@
|
|||
use mat::*;
|
||||
use vec::*;
|
||||
use std::cmp::FuzzyEq;
|
||||
|
||||
// TODO
|
||||
|
||||
|
@ -57,10 +58,10 @@ fn test_mat2() {
|
|||
assert!(a.dot(&b) == 40.0);
|
||||
|
||||
assert!(a.transpose() == mat2::new(1.0, 2.0,
|
||||
3.0, 4.0));
|
||||
3.0, 4.0));
|
||||
|
||||
assert!(option::unwrap(a.inverse()) == mat2::new(-2.0, 1.5,
|
||||
1.0, -0.5));
|
||||
assert!(a.inverse().unwrap() == mat2::new(-2.0, 1.5,
|
||||
1.0, -0.5));
|
||||
|
||||
assert!(mat2::new(0.0, 2.0,
|
||||
0.0, 5.0).inverse().is_none());
|
||||
|
@ -144,7 +145,7 @@ fn test_mat2_mut() {
|
|||
mut_a = a;
|
||||
|
||||
mut_a.invert_self();
|
||||
assert!(mut_a == option::unwrap(a.inverse()));
|
||||
assert!(mut_a == a.inverse().unwrap());
|
||||
mut_a = a;
|
||||
|
||||
mut_a.transpose_self();
|
||||
|
@ -230,16 +231,16 @@ fn test_mat3() {
|
|||
|
||||
assert!(a.inverse().is_none());
|
||||
|
||||
assert!(option::unwrap(mat3::new(2.0, 4.0, 6.0,
|
||||
0.0, 2.0, 4.0,
|
||||
0.0, 0.0, 1.0).inverse())
|
||||
assert!(mat3::new(2.0, 4.0, 6.0,
|
||||
0.0, 2.0, 4.0,
|
||||
0.0, 0.0, 1.0).inverse().unwrap()
|
||||
== mat3::new(0.5, -1.0, 1.0,
|
||||
0.0, 0.5, -2.0,
|
||||
0.0, 0.0, 1.0));
|
||||
|
||||
let ident: Mat3<float> = Matrix::identity();
|
||||
|
||||
assert!(option::unwrap(ident.inverse()) == ident);
|
||||
assert!(ident.inverse().unwrap() == ident);
|
||||
|
||||
assert!(ident.is_identity());
|
||||
assert!(ident.is_symmetric());
|
||||
|
@ -333,7 +334,7 @@ fn test_mat3_mut() {
|
|||
mut_a = a;
|
||||
|
||||
mut_c.invert_self();
|
||||
assert!(mut_c == option::unwrap(c.inverse()));
|
||||
assert!(mut_c == c.inverse().unwrap());
|
||||
// mut_c = c;
|
||||
|
||||
mut_a.transpose_self();
|
||||
|
@ -542,7 +543,7 @@ fn test_mat4_mut() {
|
|||
mut_a = a;
|
||||
|
||||
mut_c.invert_self();
|
||||
assert!(mut_c == option::unwrap(c.inverse()));
|
||||
assert!(mut_c == c.inverse().unwrap());
|
||||
// mut_c = c;
|
||||
|
||||
mut_a.transpose_self();
|
||||
|
@ -553,11 +554,11 @@ fn test_mat4_mut() {
|
|||
#[test]
|
||||
fn test_mat4_fuzzy_eq() {
|
||||
assert!(!mat4::new(0.000001, 0.000001, 0.000001, 0.000001,
|
||||
0.000001, 0.000001, 0.000001, 0.000001,
|
||||
0.000001, 0.000001, 0.000001, 0.000001,
|
||||
0.000001, 0.000001, 0.000001, 0.000001).fuzzy_eq(&mat4::zero()));
|
||||
0.000001, 0.000001, 0.000001, 0.000001,
|
||||
0.000001, 0.000001, 0.000001, 0.000001,
|
||||
0.000001, 0.000001, 0.000001, 0.000001).fuzzy_eq(&mat4::zero()));
|
||||
assert!(mat4::new(0.0000001, 0.0000001, 0.0000001, 0.0000001,
|
||||
0.0000001, 0.0000001, 0.0000001, 0.0000001,
|
||||
0.0000001, 0.0000001, 0.0000001, 0.0000001,
|
||||
0.0000001, 0.0000001, 0.0000001, 0.0000001).fuzzy_eq(&mat4::zero()));
|
||||
0.0000001, 0.0000001, 0.0000001, 0.0000001,
|
||||
0.0000001, 0.0000001, 0.0000001, 0.0000001,
|
||||
0.0000001, 0.0000001, 0.0000001, 0.0000001).fuzzy_eq(&mat4::zero()));
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
use std::cmp::FuzzyEq;
|
||||
use numeric::*;
|
||||
|
||||
use mat::*;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use std::cmp::FuzzyEq;
|
||||
use numeric::*;
|
||||
use numeric::float::Float;
|
||||
|
||||
use vec::*;
|
||||
|
@ -58,11 +57,11 @@ fn test_vec2() {
|
|||
assert!(mut_a == -a);
|
||||
mut_a = a;
|
||||
|
||||
mut_a.mul_self_t(&f1);
|
||||
mut_a.mul_self_t(f1);
|
||||
assert!(mut_a == a.mul_t(f1));
|
||||
mut_a = a;
|
||||
|
||||
mut_a.div_self_t(&f2);
|
||||
mut_a.div_self_t(f2);
|
||||
assert!(mut_a == a.div_t(f2));
|
||||
mut_a = a;
|
||||
|
||||
|
@ -110,7 +109,7 @@ fn test_vec2_euclidean() {
|
|||
|
||||
assert!(vec2::new(1.0, 0.0).angle(&vec2::new(0.0, 1.0)).fuzzy_eq(&Float::frac_pi_2()));
|
||||
assert!(vec2::new(10.0, 0.0).angle(&vec2::new(0.0, 5.0)).fuzzy_eq(&Float::frac_pi_2()));
|
||||
assert!(vec2::new(-1.0, 0.0).angle(&vec2::new(0.0, 1.0)).fuzzy_eq(&Float::frac_pi_2()));
|
||||
assert!(vec2::new(-1.0, 0.0).angle(&vec2::new(0.0, 1.0)).fuzzy_eq(&-Float::frac_pi_2::<f32>()));
|
||||
|
||||
assert!(vec2::new(3.0, 4.0).normalize().fuzzy_eq(&vec2::new(3.0/5.0, 4.0/5.0)));
|
||||
// TODO: test normalize_to, normalize_self, and normalize_self_to
|
||||
|
@ -121,7 +120,7 @@ fn test_vec2_euclidean() {
|
|||
assert!(c.lerp(&d, 0.75) == vec2::new(0.250, -0.250));
|
||||
|
||||
let mut mut_c = c;
|
||||
mut_c.lerp_self(&d, &0.75);
|
||||
mut_c.lerp_self(&d, 0.75);
|
||||
assert!(mut_c == c.lerp(&d, 0.75));
|
||||
}
|
||||
|
||||
|
@ -211,11 +210,11 @@ fn test_vec3() {
|
|||
assert!(mut_a == -a);
|
||||
mut_a = a;
|
||||
|
||||
mut_a.mul_self_t(&f1);
|
||||
mut_a.mul_self_t(f1);
|
||||
assert!(mut_a == a.mul_t(f1));
|
||||
mut_a = a;
|
||||
|
||||
mut_a.div_self_t(&f2);
|
||||
mut_a.div_self_t(f2);
|
||||
assert!(mut_a == a.div_t(f2));
|
||||
mut_a = a;
|
||||
|
||||
|
@ -278,7 +277,7 @@ fn test_vec3_euclidean() {
|
|||
assert!(c.lerp(&d, 0.75) == vec3::new(0.250, -0.250, 0.625));
|
||||
|
||||
let mut mut_c = c;
|
||||
mut_c.lerp_self(&d, &0.75);
|
||||
mut_c.lerp_self(&d, 0.75);
|
||||
assert!(mut_c == c.lerp(&d, 0.75));
|
||||
}
|
||||
|
||||
|
@ -368,11 +367,11 @@ fn test_vec4() {
|
|||
assert!(mut_a == -a);
|
||||
mut_a = a;
|
||||
|
||||
mut_a.mul_self_t(&f1);
|
||||
mut_a.mul_self_t(f1);
|
||||
assert!(mut_a == a.mul_t(f1));
|
||||
mut_a = a;
|
||||
|
||||
mut_a.div_self_t(&f2);
|
||||
mut_a.div_self_t(f2);
|
||||
assert!(mut_a == a.div_t(f2));
|
||||
mut_a = a;
|
||||
|
||||
|
@ -431,7 +430,7 @@ fn test_vec4_euclidean() {
|
|||
assert!(c.lerp(&d, 0.75) == vec4::new(0.250, -0.250, 0.625, 1.250));
|
||||
|
||||
let mut mut_c = c;
|
||||
mut_c.lerp_self(&d, &0.75);
|
||||
mut_c.lerp_self(&d, 0.75);
|
||||
assert!(mut_c == c.lerp(&d, 0.75));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue