Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcroomp committed Jul 7, 2024
1 parent b50d058 commit 292cfc4
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/all_tests/t_i16x8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,9 @@ fn impl_i16x8_mul_widen() {
]);
let actual = a.mul_widen(b);
assert_eq!(expected, actual);

crate::test_random_vector_vs_scalar(
|a: i16x8, b| a.mul_widen(b),
|a, b| i32::from(a) * i32::from(b),
);
}
5 changes: 5 additions & 0 deletions tests/all_tests/t_i32x8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ fn impl_from_u16x8() {
]);

assert_eq!(actual, expected);

crate::test_random_vector_vs_scalar(
|a: u16x8, _b| i32x8::from_u16x8(a),
|a, _b| a as u32 as i32,
);
}

#[test]
Expand Down
15 changes: 15 additions & 0 deletions tests/all_tests/t_u16x16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,21 @@ fn impl_u16x16_max() {
crate::test_random_vector_vs_scalar(|a: u16x16, b| a.max(b), |a, b| a.max(b));
}

#[test]
fn impl_u16x16_from_u8x16() {
let v = [10u8, 2, 3, 4, 5, 6, 7, 8, 9, 7, 127, 12, 13, 6, 55, 255];

assert_eq!(
u16x16::from(v.map(|a| u16::from(a))),
u16x16::from(u8x16::from(v))
);

crate::test_random_vector_vs_scalar(
|a: u8x16, _b| u16x16::from(a),
|a, _b| u16::from(a),
);
}

#[test]
fn impl_u16x16_min() {
let a = u16x16::from([1, 2, 1, 0, 6, 8, 12, 9, 1, 2, 1, 0, 6, 8, 12, 9]);
Expand Down
23 changes: 23 additions & 0 deletions tests/all_tests/t_u16x8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,26 @@ fn impl_u16x8_from_u8x16_high() {
let actual = u16x8::from_u8x16_high(a);
assert_eq!(expected, actual);
}

#[test]
fn impl_u16x8_mul_widen() {
let a = u16x8::from([1, 2, 3, 4, 5, 6, i16::MAX as u16, u16::MAX]);
let b = u16x8::from([17, 18, 190, 20, 21, 22, i16::MAX as u16, u16::MAX]);
let expected = u32x8::from([
17,
36,
570,
80,
105,
132,
(i16::MAX as u32) * (i16::MAX as u32),
(u16::MAX as u32) * (u16::MAX as u32),
]);
let actual = a.mul_widen(b);
assert_eq!(expected, actual);

crate::test_random_vector_vs_scalar(
|a: u16x8, b| a.mul_widen(b),
|a, b| u32::from(a) * u32::from(b),
);
}
23 changes: 23 additions & 0 deletions tests/all_tests/t_u32x8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,26 @@ fn impl_u32x8_not() {

crate::test_random_vector_vs_scalar(|a: u32x8, _b| !a, |a, _b| !a);
}

#[test]
fn impl_u32x8_from_u16x8() {
let a = u16x8::from([1, 2, 3, 4, 5, i16::MAX as u16, u16::MAX - 1, u16::MAX]);
let actual = u32x8::from(a);
let expected = u32x8::from([
1,
2,
3,
4,
5,
i16::MAX as u32,
(u16::MAX - 1) as u32,
u16::MAX as u32,
]);

assert_eq!(actual, expected);

crate::test_random_vector_vs_scalar(
|a: u16x8, _b| u32x8::from(a),
|a, _b| a as u32,
);
}

0 comments on commit 292cfc4

Please sign in to comment.