Skip to content

Commit

Permalink
Merge pull request rust-windowing#184 from luisbg/master
Browse files Browse the repository at this point in the history
Add more tests for F32x4
  • Loading branch information
pcwalton authored Jun 6, 2019
2 parents 9f9233c + 70e9adc commit 1897cc5
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions simd/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,26 @@ fn test_f32x4_accessors_and_mutators() {
fn test_f32x4_basic_ops() {
let a = F32x4::new(1.0, 3.0, 5.0, 7.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.max(b), F32x4::new(2.0, 3.0, 6.0, 7.0));
let c = F32x4::new(-1.0, 1.0, -20.0, 3.0);
assert_eq!(c.abs(), 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.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]
fn test_f32x4_packed_comparisons() {
let a = F32x4::new(7.0, 3.0, 6.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_gt(b), U32x4::new(0, 0, !0, 0));
assert_eq!(a.packed_le(b), U32x4::new(!0, !0, 0, !0));
}

#[test]
Expand Down Expand Up @@ -363,6 +372,12 @@ fn test_f32x4_conversions() {
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

#[test]
Expand Down

0 comments on commit 1897cc5

Please sign in to comment.