Add more tests for F32x4

This commit is contained in:
Luis de Bethencourt 2019-06-05 17:30:31 -04:00
parent 893f735a2b
commit 70e9adc0da
1 changed files with 17 additions and 2 deletions

View File

@ -37,10 +37,17 @@ fn test_f32x4_accessors_and_mutators() {
fn test_f32x4_basic_ops() { fn test_f32x4_basic_ops() {
let a = F32x4::new(1.0, 3.0, 5.0, 7.0); let a = F32x4::new(1.0, 3.0, 5.0, 7.0);
let b = F32x4::new(2.0, 2.0, 6.0, 6.0); let b = F32x4::new(2.0, 2.0, 6.0, 6.0);
assert_eq!(a.approx_recip(), F32x4::new(0.99975586, 0.33325195, 0.19995117, 0.14282227));
assert_eq!(a.min(b), F32x4::new(1.0, 2.0, 5.0, 6.0)); assert_eq!(a.min(b), F32x4::new(1.0, 2.0, 5.0, 6.0));
assert_eq!(a.max(b), F32x4::new(2.0, 3.0, 6.0, 7.0)); assert_eq!(a.max(b), F32x4::new(2.0, 3.0, 6.0, 7.0));
let c = F32x4::new(-1.0, 1.0, -20.0, 3.0); let c = F32x4::new(-1.0, 1.3, -20.0, 3.6);
assert_eq!(c.abs(), F32x4::new(1.0, 1.0, 20.0, 3.0)); assert_eq!(c.clamp(a, b), F32x4::new(1.0, 2.0, 5.0, 6.0));
assert_eq!(c.abs(), F32x4::new(1.0, 1.3, 20.0, 3.6));
assert_eq!(c.floor(), F32x4::new(-1.0, 1.0, -20.0, 3.0));
assert_eq!(c.ceil(), F32x4::new(-1.0, 2.0, -20.0, 4.0));
assert_eq!(c.round(), F32x4::new(-1.0, 1.0, -20.0, 4.0));
let d = F32x4::new(1.0, 2.0, 3.0, 4.0);
assert_eq!(d.sqrt(), F32x4::new(1.0, 1.4142135, 1.7320508, 2.0));
} }
#[test] #[test]
@ -48,6 +55,8 @@ fn test_f32x4_packed_comparisons() {
let a = F32x4::new(7.0, 3.0, 6.0, -2.0); let a = F32x4::new(7.0, 3.0, 6.0, -2.0);
let b = F32x4::new(10.0, 3.0, 5.0, -2.0); let b = F32x4::new(10.0, 3.0, 5.0, -2.0);
assert_eq!(a.packed_eq(b), U32x4::new(0, !0, 0, !0)); assert_eq!(a.packed_eq(b), U32x4::new(0, !0, 0, !0));
assert_eq!(a.packed_gt(b), U32x4::new(0, 0, !0, 0));
assert_eq!(a.packed_le(b), U32x4::new(!0, !0, 0, !0));
} }
#[test] #[test]
@ -363,6 +372,12 @@ fn test_f32x4_conversions() {
assert_eq!(a.to_i32x4(), I32x4::new(48, -4, 200, 7)); assert_eq!(a.to_i32x4(), I32x4::new(48, -4, 200, 7));
} }
#[test]
fn test_f32x4_debug() {
let a = F32x4::new(48.0, -4.0, 200.0, 7.0);
assert_eq!("<48, -4, 200, 7>", format!("{:?}", a));
}
// I32x4 // I32x4
#[test] #[test]