2021-09-08 20:01:16 -04:00
|
|
|
#![feature(portable_simd, generic_const_exprs, adt_const_params)]
|
2021-07-28 04:19:31 +00:00
|
|
|
#![allow(incomplete_features)]
|
2021-09-08 20:01:16 -04:00
|
|
|
#![cfg(feature = "generic_const_exprs")]
|
2021-07-19 19:13:24 -04:00
|
|
|
|
2023-05-11 12:13:00 -07:00
|
|
|
use core_simd::simd::Simd;
|
2021-05-24 08:37:15 -04:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn byte_convert() {
|
2021-08-07 21:06:40 +00:00
|
|
|
let int = Simd::<u32, 2>::from_array([0xdeadbeef, 0x8badf00d]);
|
2021-05-24 08:37:15 -04:00
|
|
|
let bytes = int.to_ne_bytes();
|
2021-07-23 20:43:53 -04:00
|
|
|
assert_eq!(int[0].to_ne_bytes(), bytes[..4]);
|
2021-05-24 08:37:15 -04:00
|
|
|
assert_eq!(int[1].to_ne_bytes(), bytes[4..]);
|
2021-08-07 21:06:40 +00:00
|
|
|
assert_eq!(Simd::<u32, 2>::from_ne_bytes(bytes), int);
|
2021-05-24 08:37:15 -04:00
|
|
|
}
|