summaryrefslogtreecommitdiff
path: root/library/portable-simd/crates/core_simd/tests/to_bytes.rs
blob: be0ee4349c579ceb6d89f55a88977bed48fc36cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#![feature(portable_simd, generic_const_exprs, adt_const_params)]
#![allow(incomplete_features)]
#![cfg(feature = "generic_const_exprs")]

use core_simd::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);
}