diff --git a/fixed_wide/src/tests.rs b/fixed_wide/src/tests.rs index 879a7fe..01fb9f1 100644 --- a/fixed_wide/src/tests.rs +++ b/fixed_wide/src/tests.rs @@ -1,4 +1,17 @@ use crate::types::I32F32; +use crate::types::I256F256; + +#[test] +fn you_can_add_numbers(){ + let a=I256F256::from((3i128*2).pow(4)); + assert_eq!(a+a,I256F256::from((3i128*2).pow(4)*2)) +} + +#[test] +fn you_can_shr_numbers(){ + let a=I32F32::from(4); + assert_eq!(a>>1,I32F32::from(2)) +} #[test] fn test_wide_mul(){ @@ -7,6 +20,18 @@ fn test_wide_mul(){ assert_eq!(aa,crate::types::I64F64::ONE); } +#[test] +fn test_wide_mul_repeated() { + let a=I32F32::from(2); + let b=I32F32::from(3); + + let w1=a.wide_mul_1_1(b); + let w2=w1.wide_mul_2_2(w1); + let w3=w2.wide_mul_4_4(w2); + + assert_eq!(w3,I256F256::from((3i128*2).pow(4))); +} + #[test] fn test_bint(){ let a=I32F32::ONE; diff --git a/fixed_wide_vectors/src/tests/fixed_wide_traits.rs b/fixed_wide_vectors/src/tests/fixed_wide_traits.rs index bbc1df1..73a0a1b 100644 --- a/fixed_wide_vectors/src/tests/fixed_wide_traits.rs +++ b/fixed_wide_vectors/src/tests/fixed_wide_traits.rs @@ -8,18 +8,6 @@ type Planar64Wide1=fixed_wide::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)); diff --git a/fixed_wide_vectors/src/tests/tests.rs b/fixed_wide_vectors/src/tests/tests.rs index 25982f7..8b13789 100644 --- a/fixed_wide_vectors/src/tests/tests.rs +++ b/fixed_wide_vectors/src/tests/tests.rs @@ -1,16 +1 @@ -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)) -}