split tests
This commit is contained in:
parent
9f9e8c793b
commit
617952c1e3
51
fixed_wide_vectors/src/tests/fixed_wide_traits.rs
Normal file
51
fixed_wide_vectors/src/tests/fixed_wide_traits.rs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
use fixed_wide_traits::wide::WideMul;
|
||||||
|
use fixed_wide_traits::wide::WideDot;
|
||||||
|
|
||||||
|
use crate::Vector3;
|
||||||
|
|
||||||
|
type Planar64=fixed_wide::types::I32F32;
|
||||||
|
//type Planar64Wide1=fixed::types::I64F64;
|
||||||
|
//type Planar64Wide2=fixed_wide::types::I128F128;
|
||||||
|
type Planar64Wide3=fixed_wide::types::I256F256;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn wide_int64() {
|
||||||
|
let a=Planar64::from(2);
|
||||||
|
let b=Planar64::from(3);
|
||||||
|
|
||||||
|
let w1=a.wide_mul(b);
|
||||||
|
let w2=w1.wide_mul(w1);
|
||||||
|
let w3=w2.wide_mul(w2);
|
||||||
|
|
||||||
|
assert_eq!(w3,Planar64Wide3::from((3i128*2).pow(4)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn wide_vec3(){
|
||||||
|
let v=Vector3::from_value(Planar64::from(3));
|
||||||
|
let v1=v.wide_mul(v);
|
||||||
|
let v2=v1.wide_mul(v1);
|
||||||
|
let v3=v2.wide_mul(v2);
|
||||||
|
|
||||||
|
assert_eq!(v3,Vector3::from_value(Planar64Wide3::from(3i128.pow(8))));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn wide_vec3_dot(){
|
||||||
|
let v=Vector3::from_value(Planar64::from(3));
|
||||||
|
let v1=v.wide_mul(v);
|
||||||
|
let v2=v1.wide_mul(v1);
|
||||||
|
let v3=v2.wide_dot(v2);
|
||||||
|
|
||||||
|
assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn wide_vec3_length_squared(){
|
||||||
|
let v=Vector3::from_value(Planar64::from(3));
|
||||||
|
let v1=v.wide_mul(v);
|
||||||
|
let v2=v1.wide_mul(v1);
|
||||||
|
let v3=v2.wide_length_squared();
|
||||||
|
|
||||||
|
assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3));
|
||||||
|
}
|
@ -1,63 +1,5 @@
|
|||||||
use fixed_wide_traits::wide::WideMul;
|
mod tests;
|
||||||
use fixed_wide_traits::wide::WideDot;
|
|
||||||
|
|
||||||
use crate::Vector3;
|
|
||||||
|
|
||||||
type Planar64=fixed_wide::types::I32F32;
|
#[cfg(feature="fixed_wide_traits")]
|
||||||
//type Planar64Wide1=fixed::types::I64F64;
|
mod fixed_wide_traits;
|
||||||
//type Planar64Wide2=fixed_wide::types::I128F128;
|
|
||||||
type Planar64Wide3=fixed_wide::types::I256F256;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn wide_int64() {
|
|
||||||
let a=Planar64::from(2);
|
|
||||||
let b=Planar64::from(3);
|
|
||||||
|
|
||||||
let w1=a.wide_mul(b);
|
|
||||||
let w2=w1.wide_mul(w1);
|
|
||||||
let w3=w2.wide_mul(w2);
|
|
||||||
|
|
||||||
assert_eq!(w3,Planar64Wide3::from((3i128*2).pow(4)));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn you_can_add_numbers(){
|
|
||||||
let a=Planar64Wide3::from((3i128*2).pow(4));
|
|
||||||
assert_eq!(a+a,Planar64Wide3::from((3i128*2).pow(4)*2))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn you_can_shr_numbers(){
|
|
||||||
let a=Planar64::from(4);
|
|
||||||
assert_eq!(a>>1,Planar64::from(2))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn wide_vec3(){
|
|
||||||
let v=Vector3::from_value(Planar64::from(3));
|
|
||||||
let v1=v.wide_mul(v);
|
|
||||||
let v2=v1.wide_mul(v1);
|
|
||||||
let v3=v2.wide_mul(v2);
|
|
||||||
|
|
||||||
assert_eq!(v3,Vector3::from_value(Planar64Wide3::from(3i128.pow(8))));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn wide_vec3_dot(){
|
|
||||||
let v=Vector3::from_value(Planar64::from(3));
|
|
||||||
let v1=v.wide_mul(v);
|
|
||||||
let v2=v1.wide_mul(v1);
|
|
||||||
let v3=v2.wide_dot(v2);
|
|
||||||
|
|
||||||
assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn wide_vec3_length_squared(){
|
|
||||||
let v=Vector3::from_value(Planar64::from(3));
|
|
||||||
let v1=v.wide_mul(v);
|
|
||||||
let v2=v1.wide_mul(v1);
|
|
||||||
let v3=v2.wide_length_squared();
|
|
||||||
|
|
||||||
assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3));
|
|
||||||
}
|
|
||||||
|
16
fixed_wide_vectors/src/tests/tests.rs
Normal file
16
fixed_wide_vectors/src/tests/tests.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
type Planar64=fixed_wide::types::I32F32;
|
||||||
|
//type Planar64Wide1=fixed::types::I64F64;
|
||||||
|
//type Planar64Wide2=fixed_wide::types::I128F128;
|
||||||
|
type Planar64Wide3=fixed_wide::types::I256F256;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn you_can_add_numbers(){
|
||||||
|
let a=Planar64Wide3::from((3i128*2).pow(4));
|
||||||
|
assert_eq!(a+a,Planar64Wide3::from((3i128*2).pow(4)*2))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn you_can_shr_numbers(){
|
||||||
|
let a=Planar64::from(4);
|
||||||
|
assert_eq!(a>>1,Planar64::from(2))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user