]> git.proxmox.com Git - rustc.git/blame - src/test/ui/consts/const-int-conversion-rpass.rs
New upstream version 1.64.0+dfsg1
[rustc.git] / src / test / ui / consts / const-int-conversion-rpass.rs
CommitLineData
416331ca
XL
1// run-pass
2
b7449926
XL
3const REVERSE: u32 = 0x12345678_u32.reverse_bits();
4const FROM_BE_BYTES: i32 = i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]);
5const FROM_LE_BYTES: i32 = i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]);
6const FROM_NE_BYTES: i32 = i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]));
7const TO_BE_BYTES: [u8; 4] = 0x12_34_56_78_i32.to_be_bytes();
8const TO_LE_BYTES: [u8; 4] = 0x12_34_56_78_i32.to_le_bytes();
f035d41b 9const TO_NE_BYTES: [u8; 4] = i32::MIN.to_be().to_ne_bytes();
b7449926 10
b7449926 11fn main() {
dc9dc135
XL
12 assert_eq!(REVERSE, 0x1e6a2c48);
13 assert_eq!(FROM_BE_BYTES, 0x12_34_56_78);
14 assert_eq!(FROM_LE_BYTES, 0x78_56_34_12);
f035d41b 15 assert_eq!(FROM_NE_BYTES, i32::MIN);
dc9dc135
XL
16 assert_eq!(TO_BE_BYTES, [0x12, 0x34, 0x56, 0x78]);
17 assert_eq!(TO_LE_BYTES, [0x78, 0x56, 0x34, 0x12]);
18 assert_eq!(TO_NE_BYTES, [0x80, 0, 0, 0]);
b7449926 19}