rust/crates/core_simd/tests/to_bytes.rs
2021-08-07 21:06:40 +00:00

15 lines
463 B
Rust

#![feature(portable_simd, const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
#![cfg(feature = "const_evaluatable_checked")]
use core_simd::Simd;
#[test]
fn byte_convert() {
let int = Simd::<u32, 2>::from_array([0xdeadbeef, 0x8badf00d]);
let bytes = int.to_ne_bytes();
assert_eq!(int[0].to_ne_bytes(), bytes[..4]);
assert_eq!(int[1].to_ne_bytes(), bytes[4..]);
assert_eq!(Simd::<u32, 2>::from_ne_bytes(bytes), int);
}