| 1 |
#![allow(bad_style)] |
| 2 |
#![allow(unused_imports)] |
| 3 |
#![allow(clippy::identity_op)] |
| 4 |
|
| 5 |
use safe_arch::*; |
| 6 |
|
| 7 |
#[cfg(target_feature = "adx")] |
| 8 |
mod adx_tests; |
| 9 |
|
| 10 |
#[cfg(target_feature = "avx")] |
| 11 |
mod avx_tests; |
| 12 |
|
| 13 |
#[cfg(target_feature = "bmi1")] |
| 14 |
mod bmi1_tests; |
| 15 |
|
| 16 |
#[cfg(target_feature = "bmi2")] |
| 17 |
mod bmi2_tests; |
| 18 |
|
| 19 |
#[cfg(target_feature = "lzcnt")] |
| 20 |
mod lzcnt_tests; |
| 21 |
|
| 22 |
#[cfg(target_feature = "pclmulqdq")] |
| 23 |
mod pclmulqdq_tests; |
| 24 |
|
| 25 |
#[cfg(target_feature = "popcnt")] |
| 26 |
mod popcnt_tests; |
| 27 |
|
| 28 |
#[cfg(target_feature = "rdrand")] |
| 29 |
mod rdrand_tests; |
| 30 |
|
| 31 |
#[cfg(target_feature = "rdseed")] |
| 32 |
mod rdseed_tests; |
| 33 |
|
| 34 |
#[cfg(target_feature = "sse2")] |
| 35 |
mod sse2_tests; |
| 36 |
|
| 37 |
#[cfg(target_feature = "sse3")] |
| 38 |
mod sse3_tests; |
| 39 |
|
| 40 |
#[cfg(target_feature = "ssse3")] |
| 41 |
mod ssse3_tests; |
| 42 |
|
| 43 |
#[cfg(target_feature = "sse4.1")] |
| 44 |
mod sse4_1_tests; |
| 45 |
|
| 46 |
#[cfg(target_feature = "sse4.2")] |
| 47 |
mod sse4_2_tests; |
| 48 |
|
| 49 |
#[test] |
| 50 |
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
| 51 |
fn test_m128_size_align() { |
| 52 |
assert_eq!(core::mem::size_of::<m128>(), 16); |
| 53 |
assert_eq!(core::mem::align_of::<m128>(), 16); |
| 54 |
} |
| 55 |
|
| 56 |
#[test] |
| 57 |
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
| 58 |
fn test_m128d_size_align() { |
| 59 |
assert_eq!(core::mem::size_of::<m128d>(), 16); |
| 60 |
assert_eq!(core::mem::align_of::<m128d>(), 16); |
| 61 |
} |
| 62 |
|
| 63 |
#[test] |
| 64 |
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
| 65 |
fn test_m128i_size_align() { |
| 66 |
assert_eq!(core::mem::size_of::<m128i>(), 16); |
| 67 |
assert_eq!(core::mem::align_of::<m128i>(), 16); |
| 68 |
} |
| 69 |
|
| 70 |
#[test] |
| 71 |
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
| 72 |
fn test_m256_size_align() { |
| 73 |
assert_eq!(core::mem::size_of::<m256>(), 32); |
| 74 |
assert_eq!(core::mem::align_of::<m256>(), 32); |
| 75 |
} |
| 76 |
|
| 77 |
#[test] |
| 78 |
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
| 79 |
fn test_m256d_size_align() { |
| 80 |
assert_eq!(core::mem::size_of::<m256d>(), 32); |
| 81 |
assert_eq!(core::mem::align_of::<m256d>(), 32); |
| 82 |
} |
| 83 |
|
| 84 |
#[test] |
| 85 |
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
| 86 |
fn test_m256i_size_align() { |
| 87 |
assert_eq!(core::mem::size_of::<m256i>(), 32); |
| 88 |
assert_eq!(core::mem::align_of::<m256i>(), 32); |
| 89 |
} |
| 90 |
|
| 91 |
#[test] |
| 92 |
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
| 93 |
fn test_m128_fmt() { |
| 94 |
let f = format!("{:?}", m128::default()); |
| 95 |
assert_eq!(&f, "m128(0.0, 0.0, 0.0, 0.0)"); |
| 96 |
|
| 97 |
let f = format!("{}", m128::default()); |
| 98 |
assert_eq!(&f, "(0, 0, 0, 0)"); |
| 99 |
|
| 100 |
let f = format!("{:b}", m128::default()); |
| 101 |
assert_eq!(&f, "(0, 0, 0, 0)"); |
| 102 |
|
| 103 |
let f = format!("{:e}", m128::default()); |
| 104 |
assert_eq!(&f, "(0e0, 0e0, 0e0, 0e0)"); |
| 105 |
|
| 106 |
let f = format!("{:E}", m128::default()); |
| 107 |
assert_eq!(&f, "(0E0, 0E0, 0E0, 0E0)"); |
| 108 |
|
| 109 |
let f = format!("{:x}", m128::default()); |
| 110 |
assert_eq!(&f, "(0, 0, 0, 0)"); |
| 111 |
|
| 112 |
let f = format!("{:X}", m128::default()); |
| 113 |
assert_eq!(&f, "(0, 0, 0, 0)"); |
| 114 |
|
| 115 |
let f = format!("{:o}", m128::default()); |
| 116 |
assert_eq!(&f, "(0, 0, 0, 0)"); |
| 117 |
} |
| 118 |
|
| 119 |
#[allow(dead_code)] |
| 120 |
fn approx_eq_f32(a: f32, b: f32) -> bool { |
| 121 |
(a - b).abs() < 0.00000001 |
| 122 |
} |
| 123 |
|
| 124 |
#[allow(dead_code)] |
| 125 |
fn approx_eq_f64(a: f64, b: f64) -> bool { |
| 126 |
(a - b).abs() < 0.00000000001 |
| 127 |
} |